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.

1762 questions
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
  • 11,083
  • 9
  • 40
  • 61
44
votes
3 answers

Is there a way to check that a dictionary key is not defined in ansible task?

So in my code I have a task: - name: cool task shell: 'touch iamnotcool.txt' when: me.cool is not defined and my vars looks like: --- me: stumped: yes So when I run the task it comes back with the following error: {"failed": true, "msg":…
Luis F Hernandez
  • 683
  • 1
  • 7
  • 9
44
votes
2 answers

How do I enable additional debugging output from Ansible and Vagrant?

I am investigating Ansible for server and application provisioning. My application is currently provisioned with shell scripts in Vagrant. Rather than rewriting my scripts, I took a sample and attempted to deploy it. It appears to deploy fine, but I…
Brian Lyttle
  • 1,757
  • 1
  • 17
  • 17
41
votes
3 answers

Running Ansible task as a specific user

I am trying to run a specific Ansible task as a different user than the one who is running the playbook. My .yml file looks like this: --- - hosts: staging_servers tasks: - name: check user remote_user: someusername shell:…
errata
  • 543
  • 1
  • 6
  • 9
37
votes
3 answers

How to run multiple playbooks in order with Ansible?

I'm working on several Ansible playbooks to spin up a new server instance. There are approximately 15 different playbooks I need to run in a specific order to successfully spin up a server. My initial thought was to write a shell script that…
nulltek
  • 1,251
  • 3
  • 14
  • 22
37
votes
6 answers

Install rpm package using Ansible

How do I install .rpm package on remote machine using Ansible? The obvious solution is to use command module, but that is a bit silly. Also I would like to avoid setting up a yum repository just for one package. Is there some more pragmatic approach…
NefariousOctopus
  • 579
  • 1
  • 5
  • 9
36
votes
8 answers

Ansible: Conditionally define variables in vars file if a certain condition is met

Depending on the value(True/False) of a variable defined into the group_vars I am trying to define some variables in a vars file. Their value depends on the group var's value. My current var file looks like this: {% if my_group_var %} test: var1:…
pandoJohn
  • 415
  • 1
  • 5
  • 8
35
votes
9 answers

How can I stop ansible from writing passwords to the logfiles?

I am setting up a MySQL server and want Ansible to set the mysql-root password during installation. With the help of the internet I came up with this solution: - name: Set MySQL root password before installing debconf: name='mysql-server'…
claus
  • 571
  • 1
  • 4
  • 11
33
votes
7 answers

ansible print debug msg variable

I try to print the previously registered mosh_version variable using the ansible debug msg command like this: - name: Print mosh version debug: msg="Mosh Version: {{ mosh_version.stdout }}" It doesn't work and prints the following error: Note:…
Zulakis
  • 4,153
  • 14
  • 48
  • 76
31
votes
7 answers

How to handle SSH port changes with Ansible?

I'm trying to use Ansible for automating the setup process of new server instances. One of the setup tasks changes the default SSH port, therefore requiring me to update the hosts list. Is it possible to automate this by having Ansible fallback to a…
Miko
  • 1,759
  • 4
  • 22
  • 28
29
votes
6 answers

Ansible: How to run one Task Host by Host?

On the play-level, we have serial: 1 to allow us to run the whole play one host at a time. But I haven't found a simple way to do this on a single task. This is especially relevant, if the task in question doesn't perform proper locking (for…
Elrond
  • 586
  • 2
  • 5
  • 16
29
votes
10 answers

How to fetch multiple files from remote machine to local with Ansible

I would like to copy files from remote directory to local directory with Ansible but fetch module allows me to copy only one file. I have many servers from which I need files (same directory each server) and I don't now how to do this with Ansible.…
maayke
  • 731
  • 1
  • 6
  • 9
27
votes
1 answer

How to assign an empty value to a variable in Ansible?

If firewall_allowed_ports in: - name: port {{ item }} allowed in firewall ufw: rule: allow port: "{{ item }}" proto: tcp with_items: - 22 - "{{ firewall_allowed_ports }}" is undefined, then this error occurs: fatal:…
030
  • 5,901
  • 13
  • 68
  • 110
27
votes
4 answers

Ansible: Is it possible to "cat file" and export it's output to screen while playing a playbook and not as debug?

I wrote a playbook which installs and configures Google Authenticator per user. I want the last step of the playbook to cat the google_authenticator configuration file. Using the "debug" module I am able to get the data to be displayed on screen but…
Itai Ganot
  • 10,644
  • 29
  • 93
  • 146
27
votes
11 answers

SSH aborts with Too many authentication failures

I'm attempting to run this simple provisioning script but I'm encountering errors when running vagrant up and then vagrant provision commands. I read that I needed to create a /etc/ansible/hosts file which I've done, populating it…
Ashley
  • 528
  • 1
  • 6
  • 14