Skip to content

Instantly share code, notes, and snippets.

@tofarley
Created January 6, 2014 07:12
Show Gist options
  • Save tofarley/8279311 to your computer and use it in GitHub Desktop.
Save tofarley/8279311 to your computer and use it in GitHub Desktop.
Does not copy public keys to every created server.
---
- name: Create render slaves on Rackspace Cloud
hosts: renderslaves
user: root
connection: local
gather_facts: False
tasks:
- name: Provision a set of instances
local_action:
module: rax
creds_file: /home/tofarley/.pyrax
region: DFW
networks:
- public
- private
- rendernet
name: render-slave
flavor: 2
image: ubuntu-1204-lts-precise-pangolin
count: 5
exact_count: yes
group: slaves
files:
/root/.ssh/authorized_keys: /home/tofarley/.ssh/id_rsa.pub
wait: yes
register: rax
# Add these servers (by public IP) to a group called slaves
# so that we can ssh into them below.
- name: Add new instance to host group
local_action: add_host hostname={{item.accessIPv4}} groupname=slaves
with_items: rax.instances
- name: Install Packages
hosts: slaves
user: root
gather_facts: True
tasks:
- name: Install apt packages
action: apt state=installed pkg={{item}} update-cache=yes
with_items:
- vim
- git
- tmux
- blender
tags:
- packages
- name: Create user
hosts: slaves
user: root
gather_facts: True
vars:
# pulled from /etc/shadow
password: $somehash$
tasks:
- action: user name=tofarley password={{password}}
- name: Copy slave.blend to server
hosts: slaves
user: root
gather_facts: True
tasks:
- copy: src=/var/opt/slave.blend dest=/root/slave.blend owner=root group=root mode=0644
- name: Launch blender in tmux
hosts: slaves
user: root
gather_facts: True
tasks:
# You can attach to this session with 'tmux attach -t blender'
- command: tmux new-session -d -s blender 'blender -b slave.blend --addons netrender -a -noaudio -nojoystick' \;
@tofarley
Copy link
Author

tofarley commented Jan 6, 2014

ansible-playbook render-farm.yml -f 10 --private-key=/home/tofarley/.ssh/id_rsa -vvvv

... snip ...

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/tofarley/render-farm.retry

162.242.159.180 : ok=0 changed=0 unreachable=1 failed=0
162.242.159.246 : ok=0 changed=0 unreachable=1 failed=0
162.242.159.48 : ok=0 changed=0 unreachable=1 failed=0
23.253.64.170 : ok=8 changed=4 unreachable=0 failed=0
23.253.66.209 : ok=0 changed=0 unreachable=1 failed=0
render-slave : ok=2 changed=1 unreachable=0 failed=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment