Skip to content

Instantly share code, notes, and snippets.

View drybjed's full-sized avatar

Maciej Delmanowski drybjed

View GitHub Profile
---
- name: ensure swap file is allocated
command: dd if=/dev/zero of=/swapfile bs=1M count={{ common_swap_size }} creates=/swapfile
when: ansible_swaptotal_mb < 1
register: swapfile_init
- name: ensure swap file is created
command: mkswap /swapfile
when: swapfile_init is defined and swapfile_init.changed
---
- hosts: localhost
vars:
deploy_git_repo_path: '/tmp/git-repo'
deploy_path: '/tmp/deploy'
deploy_dirs: [ '{{ deploy_path }}', '{{ deploy_git_repo_path }}', '{{ deploy_path }}/shared', '{{ deploy_path }}/shared/public' ]
deploy_items:
---
- hosts: localhost
vars:
host_list: [ '192.168.1.1', '192.168.1.2' ]
tasks:
- shell: ping -c1 {{ item }}
---
- hosts: localhost
vars:
gateway:
'gw':
'10.1.1.0': '10.1.1.1'
'10.1.2.0': '10.1.2.1'
---
# inventory/host_vars/localhost.yml
graphite:
secret_key: 'aaa'
- name: Wait until VM is installed
virt: name={{ vm.name }}
command=status
register: virt_status
until: virt_status.status == 'shutdown'
retries: 20
delay: 60
when: {{ vm.state }} == 'running'
127.0.0.1 localhost
::1 localhost
{% for host in groups['all'] %}
{# {{ hostvars[host]['ansible_default_ipv4'].address }} {{ hostvars[host]['ansible_fqdn'] }} {{ hostvars[host]['ansible_hostname'] }} #}
{{ host }}
{{ hostvars['pyke']['ansible_default_ipv4']['address'] }}
{# {{ hostvars | to_nice_json }} #}
{% endfor %}
---
- name: ensure swap file is allocated
command: dd if=/dev/zero of=/swapfile bs=1M count={{ common_swap_size }} creates=/swapfile
when: ansible_swaptotal_mb < 1
register: swapfile_init
- name: ensure swap file is created
command: mkswap /swapfile
when: swapfile_init is defined and swapfile_init.changed
{#
Abusing Jinja2 templates 101: Postfix local facts
This template manages contents of /etc/ansible/facts.d/postfix.fact
and allows to configure Postfix ba multiple separate roles using
dependency variables. Configuration will be stored and preserved
idempotently between ansible-playbook runs.
Recognized variables:
- postfix_dependency_lists: hash variable which defines lists of values
---
- hosts: all
vars:
account: 'user.name'
migration:
target:
"user.name":