From 15bd0b203af96a18e11eb1b729d0acebebf3fbe2 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Fri, 12 Feb 2016 10:51:26 -0500 Subject: [PATCH] Checking for all file dependencies so tasks can be re-run --- roles/common/tasks/main.yml | 20 ++++++++++++++++++++ roles/proxy/tasks/main.yml | 13 +++++++++++++ roles/rails/tasks/vars.yml | 23 +++++++++++++++++++++-- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 1498765..4425f7f 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -46,29 +46,49 @@ - name: Set git email shell: git config --global user.email "jacob.wimer@gmail.com" +- name: Is docker installed + shell: which docker + resgister: docker_installed + - name: Get docker shell: curl -sSL https://get.docker.com/ | sh + when: docker_install is none - name: Get docker compose shell: curl -L https://github.com/docker/compose/releases/download/1.5.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose + when: docker_install is none - name: Link docker compose shell: chmod +x /usr/local/bin/docker-compose + when: docker_install is none - name: Set timezone to NewYork shell: timedatectl set-timezone America/New_York +- name: Is heroku installed + shell: which heroku + resgister: heroku_installed + - name: Install heroku toolbelt shell: wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh + when: heroku_installed is none + +- name: Does the update script exist + stat: path=/etc/cron.daily/update.sh + register: update_script + ignore_errors: yes - name: Create update script shell: touch /etc/cron.daily/update.sh + when: update_script|failed - name: Set update script as executable shell: chmod +x /etc/cron.daily/update.sh + when: update_script|failed - name: Add update line to update script shell: echo apt-get update && apt-get upgrade -y && apt-get clean && apt-get autoclean && apt-get autoremove -y && apt-get update >> /etc/cron.daily/update.sh + when: update_script|failed - name: test for swap partition shell: swapon -s | grep -E "^/" diff --git a/roles/proxy/tasks/main.yml b/roles/proxy/tasks/main.yml index 932d6c2..b858b7c 100644 --- a/roles/proxy/tasks/main.yml +++ b/roles/proxy/tasks/main.yml @@ -13,16 +13,29 @@ - name: Create haproxy config file template: src=../roles/proxy/templates/haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg +- name: Does does haproxy init exist + stat: path=/default/haproxy + register: haproxy_init + ignore_errors: yes + - name: Enable init script replace: dest='/etc/default/haproxy' regexp='ENABLED=0' replace='ENABLED=1' + when: haproxy_init|failed + +- name: ssl key exits + stat: path=/root/server.pem + register: ssl + ignore_errors: yes - name: Generate self signed key shell: openssl req -new -newkey rsa:4096 -sha256 -subj '/CN=home/O=home LTD./C=US' -x509 -nodes -keyout /root/server.key -out /root/server.crt + when: ssl|failed - name: Create pem file shell: cat /root/server.crt /root/server.key > /root/server.pem + when: ssl|failed - name: Restart haproxy service: name=haproxy state=restarted diff --git a/roles/rails/tasks/vars.yml b/roles/rails/tasks/vars.yml index 030cdf5..2b85499 100644 --- a/roles/rails/tasks/vars.yml +++ b/roles/rails/tasks/vars.yml @@ -2,49 +2,68 @@ # This task puts all application variables in place for both workers and webservers # +- name: Does prod.env exist + stat: path=/root/prod.env + register: prod_env + ignore_errors: yes + - name: Create prod.env shell: touch /root/prod.env + when: prod_env|failed - name: Declare env file shell: echo export WRESTLINGDEV_ENV_FILE=/root/prod.env + when: prod_env|failed - name: Set env file permanently shell: echo WRESTLINGDEV_ENV_FILE=/root/prod.env >> /etc/environment + when: prod_env|failed - name: Set DB Name shell: echo WRESTLINGDEV_DB_NAME={{ lookup('env', 'WRESTLINGDEV_DB_NAME') }} >> /root/prod.env + when: prod_env|failed - name: Set db password shell: echo WRESTLINGDEV_DB_PWD={{ lookup('env', 'WRESTLINGDEV_DB_PWD') }} >> /root/prod.env - + when: prod_env|failed - name: Set db username shell: echo WRESTLINGDEV_DB_USR={{ lookup('env', 'WRESTLINGDEV_DB_USR') }} >> /root/prod.env - + when: prod_env|failed - name: Set db host shell: echo WRESTLINGDEV_DB_HOST={{ lookup('env', 'WRESTLINGDEV_DB_HOST') }} >> /root/prod.env + when: prod_env|failed - name: Set db port shell: echo WRESTLINGDEV_DB_PORT={{ lookup('env', 'WRESTLINGDEV_DB_PORT') }} >> /root/prod.env + when: prod_env|failed - name: Set devise secret key shell: echo WRESTLINGDEV_DEVISE_SECRET_KEY={{ lookup('env', 'WRESTLINGDEV_DEVISE_SECRET_KEY') }} >> /root/prod.env + when: prod_env|failed - name: Set secret key base shell: echo WRESTLINGDEV_SECRET_KEY_BASE={{ lookup('env', 'WRESTLINGDEV_SECRET_KEY_BASE') }} >> /root/prod.env + when: prod_env|failed - name: Set new relic license shell: echo WRESTLINGDEV_NEW_RELIC_LICENSE_KEY={{ lookup('env', 'WRESTLINGDEV_NEW_RELIC_LICENSE_KEY') }} >> /root/prod.env + when: prod_env|failed - name: Set memcached username shell: echo MEMCACHIER_USERNAME={{ lookup('env', 'MEMCACHIER_USERNAME') }} >> /root/prod.env + when: prod_env|failed - name: Set memcached password shell: echo MEMCACHIER_PASSWORD={{ lookup('env', 'MEMCACHIER_PASSWORD') }} >> /root/prod.env + when: prod_env|failed - name: Set memcached servers shell: echo MEMCACHIER_SERVERS={{ lookup('env', 'MEMCACHIER_SERVERS') }} >> /root/prod.env + when: prod_env|failed - name: Set email password shell: echo WRESTLINGDEV_EMAIL_PWD={{ lookup('env', 'WRESTLINGDEV_EMAIL_PWD') }} >> /root/prod.env + when: prod_env|failed +