Last active
August 29, 2015 14:25
-
-
Save cemeng/fe2f1efdce0c3974f241 to your computer and use it in GitHub Desktop.
Ansible Ruby on Linux
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: upsydaisy | |
vars: | |
project: activsky | |
admin_user: felixt | |
project_user: activsky | |
ruby_compiler: ruby | |
ruby_version: 2.1.1 | |
install_ruby: false | |
remote_user: root | |
sudo: true | |
tasks: | |
- name: "Create admin user: {{admin_user}}" | |
action: "user name={{admin_user}} | |
update_password=always | |
groups=sudo | |
shell=/bin/bash | |
password=$6$rounds=100000$mqWi51/Z5uaL496H$5Jkl8TC9f4Lhyx2KiSYBvGQ5Sn1Q25oYO.rUlHRhfALNganalEjyMlfk/Mdx5O5OZHL5RmobuHgJ3dN8VdsH60" | |
- name: "Create project user: {{project_user}}" | |
action: "user name={{project_user}} | |
update_password=always | |
groups=sudo | |
shell=/bin/bash | |
password=$6$rounds=100000$X0dLo4kO5Wur4Kfv$7BUHaKBeW0fs5ElMBwDrVehSkLTHLGwOwb1DNZMU5CxRh8ZxlIXYw7rPFWeO5/fMgAPHIJJjvf2tdyJ5hOq44." | |
# Can't get ansible to do ssh-copy-id - needs to be done manually | |
# name: Copy ssh for xxx | |
# shell: ssh-copy-id {{project}}@{{ansible_hostname}} | |
- name: Update apt | |
apt: update_cache=yes cache_valid_time=144000 | |
- name: Install necessary packages | |
apt: pkg={{ item }} state=latest | |
with_items: | |
- build-essential | |
- git | |
- name: Install postgres | |
apt: pkg={{ item }} state=latest | |
with_items: | |
- postgresql | |
- libpq-dev | |
- python-psycopg2 # needed for postgresql ansible commands | |
- name: Download ruby-install | |
sudo: yes | |
sudo_user: "{{admin_user}}" | |
get_url: | |
url: https://github.com/postmodern/ruby-install/archive/v0.4.1.tar.gz | |
dest: /home/{{admin_user}}/ruby-install-0.4.1.tar.gz | |
- name: Extract ruby-install | |
sudo: yes | |
sudo_user: "{{admin_user}}" | |
shell: tar -xzvf ruby-install-0.4.1.tar.gz | |
- name: Install ruby-install | |
sudo: yes | |
shell: "cd /home/{{admin_user}}/ruby-install-0.4.1; make install" | |
# PROJECT SPECIFIC - need to be split | |
- include: tasks/ruby.yml | |
- include: tasks/postgres.yml | |
# TODO: | |
# name: Add ruby to path | |
# name: Use chruby | |
# name: Setup postgres user for activsky | |
# name: Deploy app | |
# Links: | |
# https://github.com/hatoishi/ansible-dev/blob/master/ruby-install/tasks/main.yml | |
# Needed to set sudoers nopasswd beforehand |
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: Postgres - create {{project}} database | |
sudo: yes | |
sudo_user: postgres | |
postgresql_db: name={{project}} | |
- name: Postgres - create user {{project}} | |
sudo: yes | |
sudo_user: postgres | |
postgresql_user: db={{project}} name={{project}} password=plaintextpasswordisawesome priv=ALL |
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: Install Ruby | |
sudo: yes | |
sudo_user: "{{project_user}}" | |
shell: /usr/local/bin/ruby-install {{ruby_compiler}} {{ruby_version}} creates=~/.rubies/{{ruby_version}} | |
when: install_ruby |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment