Questions tagged [ansible]

Ansible is an automation tool ("IT orchestration engine", per the company web site) for the deployment and configuration of applications and systems.

Ansible is an automation tool for the deployment and configuration of applications and systems. Ansible is an open source project released under the GPLv3 license. Ansible, Inc., who provides commercial support and repackaging, was acquired by Red Hat, Inc. in 2015. Ansible scripts are written using the YAML syntax.

Ansible Git Corporate site Ansible Project on Google Groups

492 questions
43
votes
3 answers

List ALL Ansible variables for a host or group with an ad hoc command?

Ansible variables come from a variety of sources. It is for example possible to provide host_vars and group_vars by creating YAML files in a subfolder named host_vars and group_vars respectively of the folder containing the inventory file. How can I…
0xC0000022L
  • 16,593
25
votes
2 answers

Ansible use inventory_hostname or ansible_hostname in task name

I am writing a rolling upgrade playbook and would like to print out the hostname of current host been upgraded. I put inventory_hostname and ansible_hostname in task names but that did not work - name: upgrade softare on {{inventory_hostname}} -…
18
votes
2 answers

How would I register a dynamically named variable in an Ansible task?

I'm trying to retrieve the group ID of two groups (syslog and utmp) by name using an Ansible task. For testing purposes I have created a playbook to retrieve the information from the Ansible host itself. --- - name: My playbook hosts: enabled …
0xC0000022L
  • 16,593
7
votes
2 answers

Ansible failed_when only print customized error message

I am writing a simple Ansible playbook to run RHEL leap second detector on Linux boxes with mixed distribution. here is the playbook --- - hosts: Linux vars_files: - ../group_vars/Linux.yml tasks: - name: Running RHEL leap second…
6
votes
1 answer

Ansible result.failed v.s. failed_when, result.changed v.s. changed_when etc

Ansible in 1.4 and later provides a way to specify this behavior as follows: - name: Fail task when the command error output prints FAILED command: /usr/bin/example-command -x -y -z register: command_result failed_when: "'FAILED' in…
sourcejedi
  • 50,249
6
votes
2 answers

How to ignore a particular output error string in Ansible and consider successful

I'm trying to ignore a particular error message in playbook output is having below error message. fatal: [192.168.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "Sending passwords in plain text without SSL/TLS is extremely insecure..…
mannoj
  • 231
5
votes
1 answer

How to override ansible_user on command line?

In group_vars/all.yml I defined a default remote user: ansible_user: blackknight But in some cases I like to override that on the command line: % ansible-playbook -u kingarthur test.yml test.yml is a simple debug playbook - hosts: localhost …
MacFreek
  • 171
5
votes
1 answer

Ansible play for creating user not setting password

Try to set a password randomly and create user with it: vars: users: - username: myuser password: "{{ 99999999999999 | random | to_uuid }}" role: - name : Add user accounts user: name: "{{ item.username }}" shell: /bin/bash …
DanH
  • 171
4
votes
1 answer

ansible.cfg become_ask_pass not working

I am using Ansible 2.5.1., and I do not want to use the flag -K all the time (I think it will be deprecated soon). I know there is a directive of become_ask_pass in the ansible.cfg file. I set this to be a true value i.e. become_ask_pass = True,…
Kamil
  • 1,461
4
votes
2 answers

Is it possible to add 2 diff cmd in ad-hoc ansible cmd?

I need to run 2 diff cmd in ad-hoc mode in ansible ?? is it possible 1] hostname 2] df -h # ansible example -s -a "hostname && df -h" Error ```[root@ansi1 ansible]# ansible example -s -a "hostname && df -h" ansi2.example.com | FAILED | rc=4…
4
votes
1 answer

Can I view tasks that will be run by ansible-playbook?

Can I review tasks that would be run by ansible-playbook? ansible-playbook --check does not list all tasks. Tasks which depend on previous tasks being performed may fail, causing ansible to stop half-way through. ansible-playbook --list-tasks does…
sourcejedi
  • 50,249
3
votes
1 answer

Ansible hide ok: [web] output but display msg

how can I hide the ok: [web] output on terminal but display the msg on the terminal. This is what I have in the ansible.cfg file. If I set display_ok_hosts=false, nothing will display on the terminal.
JakePaul
  • 61
  • 6
3
votes
1 answer

Is it possible to define run_once strategy on Ansible?

I would like to run a task only on one host with Ansible. To do that, I use the parameter run_once. But what would really rock is to be able to specify a strategy to select that one host to run that task on. For instance, the host with the highest…
Raspbeguy
  • 555
3
votes
2 answers

how to run ansibe playbooks in parallel

site.yml --- - import_playbook: common.yml - import_playbook: redis.yml - import_playbook: riak.yml - import_playbook: webserver.yml - import_playbook: haproxy.yml I want to run these playbooks in parallel. like - import_playbook: common.yml #…
Akhil
  • 1,290
3
votes
1 answer

If condition in ansible jinja2 template

Search keyword in "host_fqdn" variable. If the value has "lab.com" keyword in it, it should directly store the value to "host_fqdn" again or else it should add "lab.com" keyword to the value and store it to "host_fqdn" variable. vars: …
Pandu
  • 129
1
2 3
8 9