Questions tagged [ansible]

Use this tag for questions about Ansible, an open-source automation engine, related to using Ansible for topics such as cloud provisioning, configuration management, application deployment, etc.

From the Ansible Documentation:

Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.

From Ansible on GitHub:

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.

445 questions
34
votes
3 answers

Can I bypass host key checking in Ansible?

I'm running an Ansible playbook with a subtle hack to work on an arbitrary port forwarded port (so I can use one machine with no direct access to lots of machines). I've got a pre-task to change the ansible_port variable, so then when I start…
Peter Turner
  • 1,430
  • 4
  • 17
  • 35
33
votes
3 answers

Is there a way to run with_items loops in parallel in Ansible?

I'm running Ansible 2.2, but can upgrade if it helps. I saw this and was pretty excited, but it doesn't seem to be in this (or any) version of Ansible documentation. The problem I'm trying to solve is I've got 1000 users that I need to manage on a…
Peter Turner
  • 1,430
  • 4
  • 17
  • 35
25
votes
1 answer

Ansible: What's the difference between task, role, play and playbook?

Ansible has tasks, roles, plays and playbooks. Are those just names for different levels in a playbook organization? If not, how, exactly, do they differ from and relate to each other?
caxcaxcoatl
  • 793
  • 1
  • 7
  • 12
22
votes
3 answers

Execute multiple Ansible tasks with the same list of items

I am using an ansible playbook to configure Apache for a list of sites. The playbook has to copy the virtual host configuration template for each site into place, and then enable each site using a2ensite: - name: Install apache site conf …
Stephen Ostermiller
  • 391
  • 1
  • 3
  • 11
20
votes
2 answers

What is Ansible's config equivalent of `--vault-password-file`?

According the help of ansible-playbook one could use --user=REMOTE_USER to define the ssh user, but one could also define ansible_ssh_user: REMOTE_USER in either the host- or group_vars. Question What variable need to be defined in either the group-…
030
  • 13,235
  • 16
  • 74
  • 173
18
votes
2 answers

How do I run ansible on one host at a time and break on a failure

I've got an Ansible playbook where I want to update a number of flaky devices in sequence. I can use serial:1, but I want to stop the playbook altogether if I get a failure so I can fix it before proceeding instead of accumulating errors. I'd also…
Peter Turner
  • 1,430
  • 4
  • 17
  • 35
12
votes
2 answers

Ansible Playbook Localhost Invocation Working Directory

I want to run an ansible playbook locally (host is localhost, like -i "localhost,") and inside the Playbook obtain the working directory from which the ansible-playbook command was invoked. However, when I read out the current working directory in a…
hakre
  • 223
  • 1
  • 3
  • 6
11
votes
2 answers

Ansible Dynamic Inventory - generate inventory with ip addresses under specific tag with underscore instead of dot

I am new to Ansible. When I am using ec2.py dynamic inventory to generate inventory, after the playbook is finished to run, the results are shown as list of IP addresses under specific tag with underscore instead of dot. For example I want to run a…
Berlin
  • 780
  • 6
  • 15
10
votes
4 answers

Playbook without relative path to vars

I had already bunch of playbooks, so I started to organize them in playbooks dir. It cause there must be relative paths to vars files. Actual playbook: --- - hosts: aws_instance.jenkins-agents user: ec2-user vars_files: -…
Mailo Světel
  • 201
  • 1
  • 2
  • 4
9
votes
2 answers

Modify sudoers file with ansible playbook template

I am trying to create a sudoers file with ansible template. The sudoers file should look like below: Cmnd_Alias LS = /bin/ls Cmnd_Alias LESS = /usr/bin/less Cmnd_Alias DU = /usr/bin/du %support1 ALL=(ALL) NOPASSWD: LS, LESS, DU What I have managed…
Prakash
  • 349
  • 4
  • 5
  • 16
9
votes
5 answers

Questions about Ansible connection to remote hosts

I want to ask some questions about working of Ansible. 1 - Which shell Ansible uses when logging to remote host ? https://askubuntu.com/questions/937354/track-logins-made-via-non-interactive-shells/937716?noredirect=1#comment1486867_937716 2 - If…
luv.preet
  • 223
  • 1
  • 7
8
votes
1 answer

Referencing current variable in Ansible conditional statement?

I'm using the willshersystems.users role from ansible galaxy for creating users on ubuntu servers. Now that I've got it working consistently, I'm trying to set the state attribute based on whether the user should have access to a specific server…
bradym
  • 556
  • 2
  • 8
8
votes
1 answer

Ansible: Exclude a parameter if variable is not set

Is there a way to exclude a parameter entirely if a variable is not set? I do not want to use a default value for this, I simply do not way the parameter referenced at all. For example, --- - name: manage_aix_lvm | creating new VG #…
Dave L
  • 83
  • 1
  • 4
7
votes
1 answer

Ansible how to know what return value is provided by a specific module

From Ansible's official doc Ansible modules normally return a data structure that can be registered into a variable, or seen directly when output by the ansible program and Ansible modules normally return a data structure that can be registered…
Tran Triet
  • 819
  • 3
  • 10
  • 19
7
votes
2 answers

How to solve "E405: Remote package tasks should have a retry" in Ansible?

E405 v4.0.0 Remote package tasks should have a retry Package operations are unreliable as they require network communication and the availability of remote servers. To mitigate the potential problems, retries should be used via register:…
030
  • 13,235
  • 16
  • 74
  • 173
1
2 3
9 10