Skip to content

Instantly share code, notes, and snippets.

- debug: msg="should not appear"
- name: run the command
command: mycommand
register: myCommandResults
- name: fail if we didn't get what we expect
assert:
that: '"my output" in myCommandResults'
@tgerla
tgerla / hosts
Last active August 29, 2015 14:14
# define these as empty groups
[tag_Name_mysql]
...
[mysql:children]
tag_Name_mysql
------------------------------------------
---
- hosts: localhost
connection: local
vars:
fake_group_names:
- web
- db
tasks:
{% for i in range(ent_count) %}
{{ i }}
{% endfor %}
---
- hosts: all
remote_user: root
tasks:
- name: Say bar
shell: echo "bar"
---
- hosts: all
gather_facts: false
tasks:
- name: test possible passwords
local_action: shell sshpass -p {{ item }} ssh {{ user }}@{{ inventory_hostname }} date
register: pastpass
ignore_errors: true
---
# this play queries all servers and creates groups
- hosts: all
remote_user: root
# remote_user: someuser
# sudo: true
tasks:
- name: create dynamic groups based on OS
group_by: key=ansible_os_family
- name: Stage instance(s)
hosts: local
connection: local
user: root
gather_facts: false
vars:
keypair: mykeypair
instance_type: m1.small
security_group: default
@tgerla
tgerla / hosts
Created September 17, 2014 16:20
Ansible and NTP example
[us_east:children]
us_east_dmz_servers
us_east_db_servers
[us_east_dmz_servers]
server1
[us_east_db_servers]
server2