Questions tagged [ansible]

On-topic questions are concerned with the use of the tool itself. Installing Ansible and prerequisites, connection issues, ... are off-topic. Red Hat Ansible is a model-driven, configuration management, multi-node deployment/orchestration and remote task execution system. It uses SSH by default, so there is no special software to be installed on the nodes you manage. Ansible is written in Python but can be extended in any language.

Red Hat® Ansible® is a model-driven, configuration management, multi-node deployment/orchestration and remote task execution system. It uses SSH and Python by default, so there is no special software to be installed on the nodes you manage. Simply, it is an agentless configuration management tool. Ansible can be extended in any language, as long as the modules can process and respond with JSON.

The biggest advantage of Ansible over other configuration management technologies is, it is agent-less, i.e., no clients need to be installed, which avoids the chicken and egg problem.

The name "ansible" is taken from the science fiction concept of a machine capable of instantaneous or superluminal communication.

While only a Linux node can be used as a control machine, it remains nonetheless possible to have Windows nodes as a target into Ansible.

Ansible capabilities have gained a lot of modules to cover Infrastructure as a Service, Platform as a Service, and Service as a Service.

Ansible is also capable of interacting with a lot of network equipment like Cisco IOS, Juniper Junos or F5 Bigip.

Ansible has two major products,

  • Ansible Engine - Easily and quickly deploy IT services, applications and environments, remove barriers between IT teams by automating routine activities.

  • Ansible Tower - With Red Hat® Ansible® Tower you can centralize and control your IT infrastructure with a visual dashboard, role-based access control, job scheduling, integrated notifications and graphical inventory management. Easily embed Ansible Tower into existing tools and processes with REST API and CLI.

Relevant links:

Related tags:

23075 questions
63
votes
3 answers

Proper way to concatenate variable strings

I need to create new variable from contents of other variables. Currently I'm using something like this: - command: echo "{{ var1 }}-{{ var2 }}-{{ var3 }}" register: newvar The problem is: Usage of {{ var1 }}...{{ varN }} brings too long strings…
Timofey Stolbov
  • 4,501
  • 3
  • 40
  • 45
63
votes
2 answers

Ansible SSH private key in source control?

I have been developing an Ansible playbook for a couple of weeks, therefore, my experience with such technology is relatively short. Part of my strategy includes using a custom ansible_ssh_user for provisioning hosts throughout the inventory,…
Alejandro Ricoveri
  • 887
  • 1
  • 7
  • 11
63
votes
4 answers

Create and use group without restart

I have a task, that creates a group. - name: add user to docker group user: name=USERNAME groups=docker append=yes sudo: true In another playbook I need to run a command that relies on having the new group permission. Unfortunately this does…
Mark
  • 7,507
  • 12
  • 52
  • 88
63
votes
6 answers

Pass array in --extra-vars

How can I pass YAML array to --extra-vars in Ansible playbook? I mean if I have a playbook: - hosts: "{{ hostName }}" remote_user: admin Then I should call my playbook like ansible-playbook DeployWar.yml \ …
Tariq
  • 2,489
  • 11
  • 36
  • 61
62
votes
9 answers

Check if service exists with Ansible

I have an Ansible playbook for deploying a Java app as an init.d daemon. Being a beginner in both Ansible and Linux I'm having trouble to conditionally execute tasks on a host based on the host's status. Namely I have some hosts having the service…
EagleBeak
  • 6,939
  • 8
  • 31
  • 47
62
votes
6 answers

How to specify ansible pretasks for a role?

How should one go about defining a pretask for role dependencies. I currently have an apache role that has a user variable so in my own role in /meta/main.yml I do something like: --- dependencies: - { role: apache, user: proxy } The…
Kęstutis
  • 1,011
  • 2
  • 12
  • 22
61
votes
5 answers

Ansible date variable

I'm trying to learn how to use Ansible facts as variables, and I don't get it. When I run... $ ansible localhost -m setup ...it lists all of the facts of my system. I selected one at random to try and use it, ansible_facts.ansible_date_time.date,…
turiyag
  • 2,757
  • 2
  • 22
  • 21
61
votes
7 answers

How specify a list value as variable in ansible inventory file?

I need something like (ansible inventory file): [example] 127.0.0.1 timezone="Europe/Amsterdam" locales="en_US","nl_NL" However, ansible does not recognize 'locales' as a list.
rmuller
  • 12,062
  • 4
  • 64
  • 92
60
votes
5 answers

fatal error: ffi.h: No such file or directory on pip2 install pyOpenSSL

One of the steps I always use to install / build my Ansible agent on target nodes was pip2 install pyOpenSSL. This is a requirement for your Ansible client in order to use the standard Ansible module for creating self signed certificates for example…
onknows
  • 6,151
  • 12
  • 65
  • 109
60
votes
5 answers

Ansible: read remote file

I generate files with ansible on remote host and after this generation, I would like to read theses files in another task. I don't find any module to read remote file with ansible (lookup seems only on local host). Do you know a module like this…
Kiva
  • 9,193
  • 17
  • 62
  • 94
60
votes
1 answer

user vs sudo vs sudo_user in ansible playbooks

I have read the Ansible documentation but I am still a bit confused about the three following parameters in ansible playbooks: user, sudo, sudo_user. I have tried the following playbooks with different combination of the parameters: user:deploy =>…
Michael
  • 8,357
  • 20
  • 58
  • 86
59
votes
3 answers

Extract filename from file result in Ansible

I'm trying to use the result of Ansible find module, which return list of files it find on a specific folder. The problem is, when I iterate over the result, I do not have the file names, I only have their full paths (including the name). Is there…
toto
  • 1,197
  • 2
  • 15
  • 26
59
votes
3 answers

How to get the first element of a list from the output of setup module in Ansible?

I received the following data from the setup module: "ansible_nodename": "3d734bc2a391", "ansible_os_family": "RedHat", "ansible_pkg_mgr": "yum", "ansible_processor": [ "AuthenticAMD", "AMD PRO A10-8700B R6, 10 Compute Cores…
thinkingmonster
  • 5,063
  • 8
  • 35
  • 57
59
votes
3 answers

Ansible Handler notify vs register

So after reading Ansible docs, I found out that Handlers are only fired when tasks report changes, so for example: some tasks ... notify: nginx_restart # our handler - name: nginx_restart vs some tasks ... register: nginx_restart # do this after…
huygn
  • 980
  • 1
  • 13
  • 22
59
votes
7 answers

Ansible: deploy on multiple hosts in the same time

Is it possible to run ansible playbook, which looks like this (it is an example from this site: http://docs.ansible.com/playbooks_roles.html): - name: this is a play at the top level of a file hosts: all remote_user: root tasks: - name: say…
sebaszw
  • 1,404
  • 2
  • 14
  • 19