This file contains hidden or 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: create a list and use it for something | |
hosts: all | |
vars: | |
existing_list: [ "1","2","3","4","5","6","7","8","9"] | |
ip_list: [] | |
gather_facts: no | |
tasks: | |
- name: loop over hosts and create list of IP:PORT entries | |
set_fact: |
This file contains hidden or 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
{% for a, b in list1|zip(list2) %} | |
{{ a }}: {{ b }} | |
{% endfor %}` |
This file contains hidden or 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
--- | |
# vim: set ft=ansible: | |
- name: matching line | |
vars: | |
stdout_lines: | |
- "" | |
- "" | |
- "db_instance : localhost" | |
- "db_type : mongoDB" | |
- "db_user : " |
This file contains hidden or 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: groups | |
hosts: localhost | |
gather_facts: no | |
tasks: | |
- debug: | |
msg: "{{ item }}" | |
with_items: "{{ groups['all'] }}" | |
- command: echo "{{ item }}" | |
with_items: "{{ groups['all'] }}" |
This file contains hidden or 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
{# vim: set ft=jinja #} | |
{% for ntpserver in ntpservers %} | |
server {{ ntpserver }} | |
{% endfor %} | |
### other config ### | |
------------- | |
then for any given group you can just define ntpservers as a list: |
This file contains hidden or 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: find stuff | |
hosts: localhost | |
tasks: | |
- find: | |
paths: | |
- /etc/pam.d | |
file_type: file | |
patterns: | |
- system* |
This file contains hidden or 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: test stuff | |
hosts: all | |
gather_facts: no | |
tasks: | |
- name: set fact | |
set_fact: | |
myfact: "it is very good" | |
- name: test for it |
This file contains hidden or 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: localhost | |
vars: | |
input: " THiS IS An ExaMpLE " | |
tasks: | |
- debug: | |
msg: "just lower: XXX{{ input | lower }}XXX" | |
- debug: | |
msg: "just trim: XXX{{ input | trim }}XXX" | |
- debug: |
This file contains hidden or 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 | |
tasks: | |
- debug: | |
msg: "{{ inventory_hostname }} sensu warn: {{ sensu_check_cpu_warning }}" | |
- debug: | |
msg: "{{ inventory_hostname }} sensu crit: {{ sensu_check_cpu_critical }}" | |
- debug: |
This file contains hidden or 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
docker_container: | |
docker_host: "{{ groups['etcd']|first }}:{{ docker_port }}" | |
image "myregistry:5000/redis:2.8.21" | |
env: | |
APP_NAME: "/CA/redis" | |
volumes: | |
- "/etc/hostname:/etc/hypervisor:ro" | |
name: rmaster01 | |
hostname: rmaster01 | |
network_mode: "{{ swarm_overlay_network }}" |