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
76
votes
5 answers

Conditionally define variable in Ansible

I want to conditionally define a variable in an Ansible playbook like this: my_var: "{{ 'foo' if my_condition}}" I would like the variable to remain undefined if the condition does not resolve to true. Ansible gives the following error if I try to…
Christian
  • 4,042
  • 4
  • 26
  • 28
76
votes
9 answers

Only check whether a line present in a file (ansible)

In ansible, I need to check whether a particular line present in a file or not. Basically, I need to convert the following command to an ansible task. My goal is to only check. grep -Fxq "127.0.0.1" /tmp/my.conf
Ansuman Bebarta
  • 7,011
  • 6
  • 27
  • 44
76
votes
5 answers

Ansible notify handlers in another role

Can I notify the handler in another role? What should I do to make ansible find it? The use case is, e.g. I want to configure some service and then restart it if changed. Different OS have probably different files to edit and even the file format…
Kan Li
  • 8,557
  • 8
  • 53
  • 93
76
votes
6 answers

Where to store Ansible host file on Mac OS X

I am trying to get started with Ansible to provision my Vagrantbox, but I can’t figure out how to deal with host files. According to the documentation the should be storred in /etc/ansible/hosts, but I can’t find this on my system (Mac OS X). I also…
StenW
  • 1,964
  • 5
  • 24
  • 27
75
votes
7 answers

Ansible Ignore errors in tasks and fail at end of the playbook if any tasks had errors

I am learning Ansible. I have a playbook to clean up resources, and I want the playbook to ignore every error and keep going on till the end , and then fail at the end if there were errors. I can ignore errors with ignore_errors: yes If it was…
Illusionist
  • 5,204
  • 11
  • 46
  • 76
75
votes
3 answers

Ansible: How to test that a registered variable is not empty?

How can I test that stderr is non empty:: - name: Check script shell: . {{ venv_name }}/bin/activate && myscritp.py args: chdir: "{{ home }}" sudo_user: "{{ user }}" register: test_myscript - debug: msg='myscritp is Ok' when: not…
user3313834
  • 7,327
  • 12
  • 56
  • 99
75
votes
2 answers

Is Ansible a replacement for a CI tool like Hudson/Jenkins?

Recently, in our company, we decided to use Ansible for deployment and continuous integration. But when I started using Ansible I didn't find modules for building Java projects with Maven, or modules for running JUnit tests, or JMeter tests. So,…
Ganesh P
  • 1,075
  • 1
  • 13
  • 19
75
votes
3 answers

Displaying output of a remote command with Ansible

In an Ansible role I generate the user's SSH key. After that I want to print it to the screen and pause so the user can copy and paste it somewhere else. So far I have something like this: - name: Generate SSH keys for vagrant user user:…
Damian Moore
  • 1,306
  • 1
  • 11
  • 13
74
votes
10 answers

Ansible: To use the 'ssh' connection type with passwords, you must install the sshpass program"

Recently I created new roles called spd in my existing project. While other script works fine in the setup. This newly created fails. Please point me to what is going wrong here ansible/roles spd tasks templates …
Vikram Ranabhatt
  • 7,268
  • 15
  • 70
  • 133
74
votes
6 answers

Accessing inventory host variable in Ansible playbook

In Ansible 2.1, I have a role being called by a playbook that needs access to a host file variable. Any thoughts on how to access it? I am trying to access the ansible_ssh_host in the test1 section of the following inventory host…
ali haider
  • 19,175
  • 17
  • 80
  • 149
74
votes
4 answers

Difference between become and become_user in Ansible

Recently I started digging into Ansible and writing my own playbooks. However, I have a troubles with understanding difference between become and become_user. As I understand it become_user is something similar to su , and become means…
Andrii Rusanov
  • 4,405
  • 2
  • 34
  • 54
74
votes
7 answers

Unexpected Exception: name 'basestring' is not defined when invoking ansible2

I'm trying to execute ansible2 commands... When I do: ansible-playbook -vvv -i my/inventory my/playbook.yml I get: Unexpected Exception: name 'basestring' is not defined the full traceback was: Traceback (most recent call last): File…
code_monk
  • 9,451
  • 2
  • 42
  • 41
74
votes
3 answers

How to use arithmetic when setting a variable value in Ansible?

I would like to use a system fact for a host times a number/percentage as a base for a variable. What I am trying to do specifically is use the ansible_memtotal_mb value and multiply it by .80 to get a ramsize to then use in setting a Couchbase…
AValenti
  • 853
  • 1
  • 6
  • 7
74
votes
4 answers

Ansible creating a virtualenv

How do you create a virtualenv for a specific python version using ansible. Is there a command in the ansible standard library? I would like something like: - virtualenv: dest=venv python_version:/usr/bin/python3
user204088
  • 1,805
  • 3
  • 17
  • 21
73
votes
4 answers

SSH Agent Forwarding with Ansible

I’m using Ansible 1.5.3 and Git with ssh agent forwarding (https://help.github.com/articles/using-ssh-agent-forwarding). I can log into the server that I am managing with Ansible and test that my connection to git is correctly…
Bob Barcklay
  • 1,584
  • 1
  • 15
  • 22