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 | |
name: test stat output | |
tasks: | |
- name: check last change to file | |
stat: | |
path: '/etc/fstab' | |
register: st | |
- debug: | |
msg: "File last modified {{ansible_date_time.epoch|int - st.stat.mtime|int }} seconds ago" |
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: copy lots of stuff | |
copy: | |
src: {{ item.name }} | |
dest: {{ item.path }} | |
with_items: | |
- name: rsyslog.conf | |
path: /etc | |
- name: remote.conf | |
path: /etc/rsyslog.d |
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
# assuming a group called rsyslog_servers of which your target host is a member | |
# with this content ina vars file somewhere | |
rsyslog_server_files: | |
- rsyslog.conf | |
- rsyslog.d/00-allowedhost.conf | |
- rsyslog.d/50-default.conf | |
# and some thing like this in your role | |
- name: deploy rsyslog config |
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
#!/usr/bin/env python | |
from ansible import errors | |
import types | |
def split(input, sep=' ', maxsplit=0): | |
if not isinstance(input, types.StringTypes) or not isinstance(sep, types.StringTypes): | |
raise errors.AnsibleFilterError('split only operates on strings') | |
if maxsplit > 0: | |
return input.split(sep, maxsplit) | |
return input.split(sep) |
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: test loops | |
hosts: somegroup | |
tasks: | |
- name: api thingy | |
module: | |
args: values | |
delegate_to: someother_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
--- | |
- name: create a list and use it for something | |
hosts: all | |
vars: | |
ip_list: [] | |
gather_facts: no | |
tasks: | |
- name: loop over hosts and create list of IP:PORT entries | |
set_fact: | |
ip_list: "{{ ip_list }} + [ '{{ '%s:6379' | format(item) }}' ]" |
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
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 }}" |
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 | |
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 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 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 |
OlderNewer