Skip to content

Instantly share code, notes, and snippets.

@halberom
halberom / play.yml
Created August 26, 2015 15:45
ansible - example of using a fact in a with_items loop
---
- hosts: localhost
tasks:
- debug: msg="{{ item.src }} and {{ item.dest }}"
with_items:
- { src: "{{ ansible_hostname }}", dest: /tmp/foo }
- { src: "{{ ansible_os_family }}", dest: /tmp/bar }
@halberom
halberom / file.yml
Created August 28, 2015 21:28
valid yaml
---
-
job:
builders:
-
ssh-builder:
command: |
"sleep 60
echo $sudopass | sudo -S docker pull myimage
@halberom
halberom / users.yml
Created January 29, 2014 23:05
passing items to lookup
---
- hosts: all
vars:
users:
- user1
- user2
tasks:
- name: create users
user: name={{item}} state=present
with_items: users
@halberom
halberom / amazon.yml
Created April 15, 2014 10:04
load vars based on distribution
# vars/amazon.yml
---
foo: bar
@halberom
halberom / example_options.txt
Created April 16, 2014 15:54
modify mount options
# /tmp/example_otpions.txt
rw,noatime,data=ordered,acl
@halberom
halberom / tmp.yml
Created April 19, 2014 17:19
change the 'changed' result of a task
---
- hosts: localhost
tasks:
- name: create a tmp file
lineinfile: dest=/tmp/head line=BODY create=yes
# the task will be marked 'ok', because the output contains 'BODY', not 'HEAD'
- name: cat head
command: cat /tmp/head
register: response
- hosts: testserver
remote_user: root
roles:
- { role: configs }
- { role: users }
- { role: sudo }
@halberom
halberom / recap
Created May 20, 2014 13:57
iterate over var of manifests
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [test] ******************************************************************
ok: [localhost] => (item={'value': {'smf_name': 'trollname', 'method': 'trollimethod', 'manifest': 'trollifest'}, 'key': 'troll'}) => {
"item": {
"key": "troll",
"value": {
"manifest": "trollifest",
"method": "trollimethod",
@halberom
halberom / tmp.yml
Last active August 29, 2015 14:01
launch ec2 instance
tasks:
- name: Launch instance
ec2:
keypair: "{{ keypair }}"
instance_profile_name: "{{ instance_profile_name }}"
group: "{{ security_group }}"
region: "{{ aws_region }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
wait: yes
@halberom
halberom / foo
Created May 28, 2014 09:54
passing var to role arg
# /tmp/foo
bar