Skip to content

Instantly share code, notes, and snippets.

@jlund
jlund / gist:8698332
Created Jan 29, 2014
Ansible authorized_key module example
View gist:8698332
- name: Set up authorized_keys for the deploy user
authorized_key: user=deploy
state=present
key="{{ item }}"
with_file:
- public_keys/lund-joshua
- public_keys/smith-john
@jlund
jlund / roles--x--tasks--main.yml
Created Aug 7, 2013
Ansible: Using multiple arguments in with_items
View roles--x--tasks--main.yml
---
- name: Echo some things!
command: echo {{ item.foo }} {{ item.bar }}
with_items: echo_arguments
View main.yml
- name: Set the hostname in rc.conf
lineinfile: dest=/etc/rc.conf regexp="^hostname" line='hostname="{{ hostname }}"'
register: hostnamestatus
- name: Set the hostname
command: hostname {{ hostname }}
when: hostnamestatus.changed
@jlund
jlund / ansible-codebase-checkout.yml
Last active Dec 18, 2015
Ansible codebase checkout
View ansible-codebase-checkout.yml
- name: Check out the latest revision of the codebase and notify the proper handlers if there have been updates
git: repo=https://github.com/jlund/imgur-display.git
dest={{ imgur_display_location }}/current
sudo: yes
sudo_user: deploy
notify:
- Symlink the log directory to the shared location
- Install the bundle
- Restart the imgur-display application
@jlund
jlund / salt-log-rotation.yml
Created Jun 11, 2013
Salt State to set up log rotation for Nginx and Passenger
View salt-log-rotation.yml
# Set up log rotation for Nginx and Passenger
{% for rotate_target in 'nginx', 'passenger' %}
/etc/logrotate.d/{{ rotate_target }}:
file.managed:
- source: salt://nginx-passenger/{{ rotate_target }}-logrotate
- require:
- cmd: nginx-install
- cmd: passenger
{% endfor %}
@jlund
jlund / ansible-log-rotation.yml
Last active Apr 22, 2016
Ansible task to set up log rotation for Nginx and Passenger
View ansible-log-rotation.yml
- name: Set up log rotation for Nginx and Passenger
copy: src={{ item }}-logrotate
dest=/etc/logrotate.d/{{ item }}
with_items:
- nginx
- passenger
@jlund
jlund / salt-nginx-install.yml
Last active Dec 18, 2015
Fix for Passenger 4 installation issues in my salt-rack Salt States
View salt-nginx-install.yml
# Run the Nginx install script
nginx-install:
cmd.script:
- name: salt://nginx-passenger/install.sh
- unless: /opt/nginx/sbin/nginx -v 2>&1 | grep 1.4.1
- template: jinja
- require:
- file: nginx-source
- cmd: passenger
- file: /usr/local/bin/rake
@jlund
jlund / install.sh
Created May 30, 2013
Python Salt state source compilation example
View install.sh
#!/bin/bash
cd /usr/local/src/
tar xfj Python-3.3.2.tar.bz2
cd Python-3.3.2
./configure --prefix=/opt/python
make
make install