Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deployment/lib/provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
22 changes: 22 additions & 0 deletions provisioning/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the deal with replacing . with [.]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forces the regexp engine to interpret them as literal periods, instead of "any single character"

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
Expand Down