Questions tagged [ansible]

Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad-hoc task execution, and configuration management.

Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad-hoc task execution, and configuration management. It manages nodes over SSH and does not require any additional remote software to be installed on them. Modules work over JSON and standard output and can be written in any programming language. The system uses YAML to express reusable descriptions of systems.

The platform was created by Michael DeHaan, the author of the provisioning server application Cobbler and co-author of the Func framework for remote administration. It is included as part of the Fedora distribution of Linux, owned by Red Hat inc., and is also available for Red Hat Enterprise Linux, CentOS and Scientific Linux via Extra Packages for Enterprise Linux (EPEL) as well as other operating systems. Ansible was commercially supported and sponsored by AnsibleWorks. Since October 2015 Ansible is owned by RedHat.

It was named by DeHaan after the fictional instantaneous hyperspace communication system featured in Orson Scott Card's Ender's Game.

1634 questions
241
votes
5 answers

How to see stdout of ansible commands?

How do I see stdout for ansible-playbook commands? -v only shows ansible output, not the individual commands. It would be great if I could figure out how to do this immediately, so if something fails or hangs I can see why. e.g. - name: print to…
QuinnBaetz
  • 2,519
  • 2
  • 12
  • 3
124
votes
2 answers

What's the difference between include_tasks and import_tasks?

In Ansible 2.4, the include module is deprecated. In its place, it ships with two replacement modules, import_tasks and include_tasks. But they have very similar descriptions: include_tasks: Includes a file with a list of tasks to be executed in…
Ben S
  • 1,351
  • 2
  • 8
  • 5
120
votes
8 answers

How can I implement ansible with per-host passwords, securely?

I would like to use ansible to manage a group of existing servers. I have created an ansible_hosts file, and tested successfully (with the -K option) with commands that only target a single host ansible -i ansible_hosts host1 --sudo -K # + commands…
supervacuo
  • 1,403
  • 2
  • 11
  • 10
102
votes
7 answers

How to set default Ansible username/password for SSH connection?

I am using Ansible and I have this configuration in my inventory/all: [master] 192.168.1.10 ansible_connection=ssh ansible_ssh_user=vagrant ansible_ssh_pass=vagrant [slave] 192.168.1.11 ansible_connection=ssh ansible_ssh_user=vagrant…
Robert
  • 1,172
  • 2
  • 9
  • 10
94
votes
13 answers

Ansible: Execute task only when a tag is specified

Ansible tags can be used to run only a subset of tasks/roles. This means that by default all tasks are executed and we can only prevent some tasks to execute. Can we limit a task to be exectued only when "foo" tag is specified? Can we use current…
Taha Jahangir
  • 2,012
  • 1
  • 15
  • 16
89
votes
3 answers

Adding a user to an additional group using ansible

How can I add a user to additional groups with Ansible? For example, I would like to add a user to the sudo group without replacing the user's existing set of groups.
vdboor
  • 3,630
  • 3
  • 30
  • 32
76
votes
18 answers

Ansible stuck on gathering facts

I'm having some odd issues with my ansible box(vagrant). Everything worked yesterday and my playbook worked fine. Today, ansible hangs on "gathering facts"? Here is the verbose output: <5.xxx.xxx.xxx> ESTABLISH CONNECTION FOR USER:…
Bj Blazkowicz
  • 871
  • 1
  • 6
  • 9
76
votes
6 answers

How to unify package installation tasks in ansible?

I am starting with ansible and will use it, among others, to install packages on several Linux distros. I see in the docs that the yum and apt commands are separated - what would be the easiest way to unify them and use something like this: - name:…
WoJ
  • 3,365
  • 8
  • 46
  • 75
63
votes
7 answers

Display output with Ansible

I have a Ansible play for PGBouncer that displays some output from a stats module built into PGBouncer. My issue is that when Ansible prints the output to the terminal it mangles the newlines. Instead of seeing ---------- | OUTPUT | ---------- I…
mjallday
  • 894
  • 2
  • 8
  • 14
62
votes
7 answers

Deploying a folder of template files using ansible

Is there an easy way to deploy a folder full of template .j2 folder to a linux box, using the same name as the template, but without the .j2 extension, rather than using the template module for each file? Right now i have a long list of: - name:…
Trololololol
  • 723
  • 1
  • 5
  • 6
56
votes
4 answers

Ansible: copy template only when destination file does not exist

I'm using Ansible 1.6.6 to provision my machine. There is a template task in my playbook that creates destination file from Jinja2 template: tasks: - template: src=somefile.j2 dest=/etc/somefile.conf I do not want to replace somefile.conf if it…
Slava Fomin II
  • 1,661
  • 4
  • 17
  • 22
55
votes
1 answer

how to access host variable of a different host with Ansible?

Let's say I have a host that collects some data and it's in a group [collectors]. I also have hosts in-group [reporters]. So, I want to set a variable on reporters from groups['collectors'][0] IP address. But the playbook for setting up reporters…
hryamzik
  • 797
  • 1
  • 6
  • 9
50
votes
3 answers

Always trigger handler execution in Ansible

I'm using Ansible to provision my development server. I want it to always start some services for me. I have handlers for this purpose but what is the best way to trigger handler execution without condition, e.g. make it always work? Something like…
Slava Fomin II
  • 1,661
  • 4
  • 17
  • 22
45
votes
3 answers

Ansible security best practices

I am going to introduce Ansible into my data center, and I'm looking for some security best practice on where to locate the control machine and how to manage the SSH keys. Question 1: the control machine We of course need a control machine. The…
Mat
  • 1,783
  • 4
  • 22
  • 39
45
votes
6 answers

Appending to lists or adding keys to dictionaries in Ansible

(Related to Callbacks or hooks, and reusable series of tasks, in Ansible roles): Is there any better way to append to a list or add a key to a dictionary in Ansible than (ab)using a jina2 template expression? I know you can do something like: -…
Craig Ringer
  • 10,553
  • 9
  • 38
  • 59
1
2 3
99 100