diff --git a/deployment/lib/provision.rb b/deployment/lib/provision.rb index b1f01ca..fe955b1 100644 --- a/deployment/lib/provision.rb +++ b/deployment/lib/provision.rb @@ -10,7 +10,7 @@ upload "./provisioning", "#{tmp}/provisioning", :via => :scp, :recursive => true upload "./bower_components/genesis-wordpress/provisioning", "#{tmp}/bower_components/genesis-wordpress/provisioning", :via => :scp, :recursive => true - sudo "#{tmp}/bin/provision" + sudo "#{tmp}/bin/provision -e stage=#{stage}" rescue puts "\n" diff --git a/provisioning/roles/common/tasks/main.yml b/provisioning/roles/common/tasks/main.yml index b07f4bc..3d4812a 100644 --- a/provisioning/roles/common/tasks/main.yml +++ b/provisioning/roles/common/tasks/main.yml @@ -1,4 +1,26 @@ --- +- name: Determine optimal hostname + command: echo {{stage}}.{{domain}} + register: new_host + ignore_errors: True + when: stage is defined + +- name: Determine current hostname + command: hostname + register: old_host + ignore_errors: True + when: stage is defined + +- name: Update hostname + hostname: name={{new_host.stdout}} + sudo: yes + when: stage is defined and old_host.stdout != new_host.stdout + +- name: Update /etc/hosts for new hostname + replace: dest=/etc/hosts backup=yes regexp={{ old_host.stdout | replace(".","[.]") }} replace={{new_host.stdout}} + sudo: yes + when: stage is defined and old_host.stdout != new_host.stdout + - name: Add Node apt-repository apt_repository: repo='ppa:chris-lea/node.js' state=present sudo: yes