Skip to content

Instantly share code, notes, and snippets.

@halberom
halberom / gist:8039933
Created December 19, 2013 14:30
example of hostvars
{% for host in groups['staging'] %}
{{ hostvars[host]['yprox_hostname'] }}
{% endfor %}
@halberom
halberom / get_cloudstack_zones
Last active October 20, 2016 20:29
custom facts - very hacky
# located in /etc/ansible/library
#!/usr/bin/env python
#
# Get cloudstack zone name/id and add to ansible facts
# requires cloudmonkey >= v5 with json output set
import json
import os
{% for service in services %}
{{ service['name'] }};
{% endfor %}
@halberom
halberom / test.yml
Created December 31, 2013 10:41
iterating with links
vars:
nginx_local_servers:
- src: 'hasta.la.vista.conf'
dst: 'terminator.conf'
- src: 'boom.baby.conf'
dst: 'cafe.ole.conf'
local_src: '/tmp/sites-local'
local_dst: '/tmp/sites-enabled'
# roles/sysctl/tasks/class_x.yml
- name: do some sysctl stuff for performance cluster
sysctl: name="net.ipv4.ip_forward" value=1
@halberom
halberom / playbook_leak.yml
Last active January 1, 2016 23:29
test a vars_prompt playbook
---
- hosts: all
vars_prompt:
- name: "leaking_password"
private: yes
prompt: "Google your leaking password?"
default: "skip"
roles:
- { role: leak, when: "leaking_password != 'skip'" }
@halberom
halberom / app.yml
Created January 2, 2014 16:26
query on common elements and includes
---
- hosts: app
roles:
- common
- httpd
- { role: vmware-tools, when: ansible_virtualization_type == 'VMware' }
---
- name: install ntp
yum: pkg=ntp state=installed
@halberom
halberom / ntp.yml
Last active January 2, 2016 15:29
doing an include of a deploy task
[root@server ansible]# ansible-playbook site.yml
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [be sure ntp is installed] **********************************************
ok: [localhost]
@halberom
halberom / gist:8323584
Created January 8, 2014 20:03
temp example
---
# Creates Digital Ocean Droplet
- name: 'Create Digital Ocean Droplet'
digital_ocean: >
state=active
command=droplet
name={{droplet_name}}
client_id={{client_id}}
api_key={{api_key}}