Skip to content

Instantly share code, notes, and snippets.

@jlund
jlund / gist:8698332
Created January 29, 2014 22:20
Ansible authorized_key module example
- 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 August 7, 2013 16:42
Ansible: Using multiple arguments in with_items
---
- name: Echo some things!
command: echo {{ item.foo }} {{ item.bar }}
with_items: echo_arguments
@jlund
jlund / main.yml
Last active December 18, 2015 11:29 — forked from ScottSturdivant/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 December 18, 2015 09:38
Ansible codebase checkout
- 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 June 11, 2013 23:02
Salt State to set up log rotation for Nginx and Passenger
# 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 April 22, 2016 14:27
Ansible task to set up log rotation for Nginx and Passenger
- 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 December 18, 2015 09:28
Fix for Passenger 4 installation issues in my salt-rack Salt States
# 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 22:40
Python Salt state source compilation example
#!/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