This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible --version | |
ansible 2.1.2.0 | |
[..] | |
$ head -n1 inventory | |
test-host ansible_host=127.0.0.1 test_var=1 | |
$ ansible -m debug -a "var=test_var" -i inventory test-host | |
test-host | SUCCESS => { | |
"test_var": 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "Setting a fact" | |
set_fact: | |
spam: True | |
when: your_condition is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "users | Creating local user(s)" | |
user: | |
name: "{{ item }}" | |
password: "{{ def_local_user_password }}" | |
state: present | |
update_password: on_create | |
when: local_users_extra is defined | |
with_items: '{{ local_users_extra }}' | |
tags: "local_users" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task: | |
- name: "Check DNS records for host" | |
set_fact: | |
dns_a_record: "{{ lookup('dig', ansible_fqdn) }}" | |
dns_ptr_record: "{{ lookup('dig', ansible_default_ipv4['address'] + '/PTR') }}" | |
output: | |
TASK [core : Check DNS records for host] *************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inventory/ | |
├── customer | |
│ └── group_vars | |
└── nit | |
├── group_vars | |
└── host_vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
vars_prompt: | |
- name: "reboot_check" | |
prompt: "Should the host(s) really be rebooted?" | |
default: "no" | |
private: no | |
tasks: | |
- include: tasks/os/common/reboot.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inventory = { | |
'all': {'hosts': []}, | |
'baseline': {'hosts': []}, | |
'signed_off': {'hosts': []}, | |
'application_installation': {'hosts': []}, | |
'operational_check': {'hosts': []}, | |
'ansible': {'hosts': []}, | |
'_meta': {'hostvars': {}}, | |
} |