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
6
votes
1 answer

Send Enter key to Ansible expect responses

I'm using the expect module. - name: "WAMUI Prerequisites Installer" expect: command: "./file.bin" responses: 'PRESS \ TO CONTINUE:':'\n' Would entering '\n' in the response send the Enter key?
Anand Rao
  • 303
  • 3
  • 4
  • 8
6
votes
1 answer

Set variable if empty or not defined with ansible

In my ansible vars file, I have a variable that will sometimes be set and other times I want to dynamically set it. For example, I have an RPM that I want to install. I can manually store the location in a variable, or if I don't have a particular…
user3270760
  • 1,444
  • 5
  • 23
  • 45
6
votes
3 answers

Having ansible run a script without the exit code stopping the ssh connection

We have an ansible task which looks like the following - name: Check if that created script: verification.sh register: verification changed_when: verification.rc == 1 The above task runs a script which returns an exit signal if failed or…
MilindaD
  • 7,533
  • 9
  • 43
  • 63
6
votes
2 answers

Create set_fact variables in one role and use them in an other

I have a complicated environment with stages and users for multiple systems. The stages are: dev, int, etc. Each stage has a user for an application, let's call the user john. That leads to a user johnd for dev and johni for int and so on. To…
iamcheko
  • 111
  • 1
  • 1
  • 6
6
votes
1 answer

How to use changed_when with ansible shell module?

I have a complex shell script that is run by ansible and I do want to communicate from it to ansible when changes were made on the system, so Ansible will know that the host was modified. This is achieve by using changed_when: condition but the…
sorin
  • 161,544
  • 178
  • 535
  • 806
6
votes
3 answers

Ansible: run multiple action

I am running ansible to copy and execute the script on remote side if script not found. but I am getting this error. ERROR! conflicting action statements: copy, command How can i use multiple action in single task. --- - name: Check if the bb.sh…
Deven
  • 85
  • 1
  • 1
  • 4
6
votes
1 answer

Vagrant provisioning with Ansible fails

I'm trying to provision Ubuntu with Vagrant and Ansible. I'm working with this article and hit the error shown below. ________________________ < TASK [Gathering Facts] > ------------------------ \ ^__^ \ (oo)\_______ …
user6908430
6
votes
3 answers

Ansible set_fact array and populate it from in loop

I want to create an array and insert value from the the array IP_TO_DNS to reversed IP address. The idea is to restructure the IP address given in the argument to be matchable later in my code. Code - name: create array reversed set_fact:…
polxpolx
  • 105
  • 2
  • 2
  • 5
6
votes
3 answers

In Ansible, how do I use a variable in an inventory file in a template

I have this inventory file inventory/hosts_elk [elk-client-0] 10.11.22.22 Now I have a template, and I want to do this elk_server.yml.j2 elk_server = {{ elk-client-0 }} But that doesn't work, that is the value for {{ elk-client-0 }} does NOT get…
Chris F
  • 14,337
  • 30
  • 94
  • 192
6
votes
1 answer

Ansible template module not parsing with_items variable

I am using a simple template with only variables in it. This is how my task looks like in my playbook (actually a role being used from my playbook): - name: Ensure the conf file exists template: src: file.conf.j2 dest: '/opt/file.conf' …
felichas
  • 77
  • 1
  • 1
  • 4
6
votes
1 answer

How to use Ansible command with items?

I want to configure my Ansible playbook to copy certain lines out of my /etc/hosts file into a temporary file. This should be easy to do: --- hosts: 127.0.0.1 gather_facts: False tasks: - command: grep {{ item }} /etc/hosts >>…
Jim
  • 13,430
  • 26
  • 104
  • 155
6
votes
1 answer

using {{item}} inside a regexp in a lineinfile task of Ansible

I have a task in an Ansible playbook that is supposed to iterate with a list of users and do a lineinfile to enable access to a postgress database: - name: Postgres localhost access lineinfile: dest: "{{postgres_dest}}/data/pg_hba.conf" …
sebamontini
  • 360
  • 2
  • 10
6
votes
2 answers

Ansible recursive loop in role's default variables

How can I reuse variables in other variables in Ansible (2.1.x) without causing recursive loops? Setup Consider this roles//defaults/main.yml file: --- liquibase: version: "3.5.3" download_file:…
Markus Ratzer
  • 1,292
  • 3
  • 19
  • 29
6
votes
4 answers

Error on ansible playbook: the python mysqldb module is required

I'm trying to teach myself ansible by deploying a wordpress instance from a build server to another host server. Both servers are Ubuntu 16.04 and everything works fine until the build gets to running the mysql tasks main.yml file when i get the…
Phillip Hogan
  • 123
  • 1
  • 2
  • 9
6
votes
3 answers

How to delete local directory with ansible

I have to make delete some directory and create them on local before copy to the remote. Is there anyway to delete and create locally? Currently I'm using 'command' command: rm -r directory But warning shows as Consider using file module with…
Neil
  • 2,714
  • 11
  • 29
  • 45