I m attempting to use together the strategy free and run_once = true so I can run concurrently several tasks on multiple hosts. Ansible shows a warning during execution it is not yet supported. Any suggestions on how to achieve that?
Have you considered using the default strategy with async tasks?
Fire each task off and check for them later.
https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html#concurrent-tasks-poll-0
Related
I have a task that shuts down any running processes using my application files and it is called twice in the deployment from different roles.
The problem is that in between the two roles someone starts a new process.
Ansible skips the second stop task because it thinks the "Conditional result was False"
This then causes the deployment to fail.
How can I force ansible to not check and always run the task?
It is at a task level and not a role level so I can't use always.
How can I force Ansible to not check and always run the task?
Depending on the tasks (annot. which are not given or described in your question), to do so you may need to set
when: true
check_mode: false
Further Documentation
Basic conditionals with when
Enforcing or preventing check mode on tasks
Defining failure
we are using AWX/Ansible Tower to launch playbooks on hosts. In our case we are always running the playbook targeting one host each time a job is launched (actually launching the job using the API)
Our problem:
- When a job fails, we'd like to offer as an option to our users the possibility to re-launch the job with ability to change the extra_variables used to execute the job. At the moment on the UI the extra variable seems to be read-only. Is there a way to change that or another way to re-launch a job using the UI and changing the variables (we obviously know that using the API we can relaunch a new instance of the job using a new set of extra_variables...) ?
Thx
I would like the ansible to wait for my input in the command line for interactive script running in remote machine. "Expect" will not suite my requirement as the interactive questions keep changing.
eg
xxx.pl
This must be the user which is running service. [root:root]': y ----> i should be allowed to change in realtime
handling utilities? [/usr/bin]: y ---> same with this
This is not possible with Ansible.
Ansible packs all task scripts/parameters before sending it for execution to remote host and there is no way (as of Ansible 2.4) to get any feedback during task execution – only final result of task.
For anyone (like myself) curious about this and landing on this page per google. Looks as if it's now possible through the prompts feature! (I don't think it's even so much as a built-in module. It seems like it's just built-in. Can't find it under Ansible.Builtin Plugin Index. It's just under Playbook Advanced Features.
I'm new to an Ansible
simply i say, I wanna make a confirmation alert after tasks is started.
due to I have to use setup facts which is hosts addresses in my alert.
my process is below
to show hosts
to confirm that the users really wanna run next processes?
[in this part I need to show hosts list]
to do something....
is there any way to resolve it?
thank you.
I think Start and Step will do what you want assuming you don't have a lot of tasks in your playbook.
Run your playbook like:
ansible-playbook playbook.yml --step
From the docs:
This will cause ansible to stop on each task, and ask if it should execute that task.
The tradeoff is that you're going to get prompted for every task, so this is really only suitable if the number of tasks is small. Also, do you really want to run your playbook interactively?
You may want to try pause module.
- pause: prompt="Make sure that {{my_custom_fact_ip_address}} is correct..."
I've switched from Capistrano 2 to Capistrano 3 recently, a lot has changed, and I'm having some troubles trying to adapt the new Capistrano to what it was being done with Capistrano 2 in the project I'm working on.
The biggest problem I'm facing at the moment is filtering by roles. I know you can do:
ROLES=web,worker cap production deploy
but if you have a single server with all the roles, that seems to do nothing really.
With Capistrano 2 I could run:
cap worker deploy
and all worker tasks would be applied. Capistrano 2 had the roles specified on the tasks and if the role wasn't requested the tasks was skipped (in most cases). However it does not seem the case for Capistrano 3, the filter is great on a multi server environment where you have specific servers for each role. But if servers share a role or if there's a single one, it gets a bit weird. In the new Capistrano tasks seems to check whether there is a host with a given role rather than checking if the task should run or not based on the role. It seems to me that ROLES is intended to limit the servers rather than the tasks.
So I wonder if this is possible in Capistrano 3. Another way of viewing this is grouping tasks under a name. I would like to select which group of tasks are being executed.
I can achieve this with some tinkering, I could check if ROLES is present and skip a task or not based on it, I could select which recipes to load depending on role, I could dynamically attach the tasks based on the ROLES var, or maybe group the tasks in role named files and do that dynamic loading depending on ROLES, etc, but perhaps there's something I'm missing.
Any thoughts?
It seems to me that ROLES is intended to limit the servers rather than the tasks.
Yes, that is exactly right. In Capistrano 3, tasks have no relation to roles whatsoever. Within a task, commands can be executed on servers that match a certain role. When you filter using ROLES, you limit the servers where the commands are run, but you don't limit the tasks themselves.
One way you could limit tasks is to define your own high-level task that invokes the tasks you want.
For example:
# In deploy.rb
task "worker" do
invoke "task1"
invoke "task2"
# etc.
end
This defines a worker task that in turn executes a specific list of tasks, which can be whatever you want. Then you can run:
cap production worker
Which will run all these worker-related tasks on your production server.