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: ensure swap file is allocated | |
command: dd if=/dev/zero of=/swapfile bs=1M count={{ common_swap_size }} | |
when: ansible_swaptotal_mb < 1 | |
- name: ensure swap file is created | |
command: mkswap /swapfile | |
when: ansible_swaptotal_mb < 1 | |
- name: ensure swap file is added to fstab | |
action: lineinfile dest=/etc/fstab regexp="swapfile" line="/swapfile none swap sw 0 0" state=present |
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
# this works because on the remote machine /home/deploy exists (in this case common_user == 'deploy') | |
- name: ensure a deploy user is created | |
user: name={{ common_user }} comment="Mr. Deploy" | |
# this fails and I'm unsure of the syntax for the key , but the error seems to be related to the user? | |
- authorized_key: user={{ common_user }} key="{{ lookup('file', {{ common_ssh_key_path }}) }}" |
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
$ ansible-playbook -i hosts site.yml | |
ERROR: expecting dict; got: h |
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
# common/defaults/main.yml | |
--- | |
common_ssh_port: 44444 | |
# group_vars/all | |
--- | |
ansible_ssh_port: "{{ common_ssh_port }}" |
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
--- | |
foo_project: | |
app: | |
domain: | |
name: foo.com | |
===== | |
vs. | |
===== |
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: restart nginx | |
service: name=nginx state=restarted |
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: restart fail2ban | |
service: name=fail2ban state=restarted |
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: | |
- name: Open the correct IPTables ports | |
lineinfile: dest=/etc/sysconfig/iptables | |
regexp="^-A INPUT -p {{item.protocol}} -m {{item.protocol}} --dport {{item.port}} -j ACCEPT$" | |
line="-A INPUT -p {{item.protocol}} -m {{item.protocol}} --dport {{item.port}} -j ACCEPT" | |
insertafter="^:OUTPUT ACCEPT \[\d*:\d*\]$" | |
with_items: | |
- { protocol: tcp, port: 80 } | |
- { protocol: tcp, port: 443 } |
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
# roles/database/handlers/main.yml | |
--- | |
- name: restart postgres | |
service: name=postgres state=restarted |
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
#!/bin/bash | |
# bootstrap-ansible.sh: download and build Ansible on Debian host | |
# https://github.com/ginas/ginas/ | |
set -e | |
# Create temporary directory for build | |
build_dir=$(mktemp -d) | |
trap "rm -rf ${build_dir}" EXIT |