Skip to content

Commit 28e395a

Browse files
committed
Experimenting with using hostname rather than IP to SSH into host.
User needs ot have avahi-daemon installed though. Also trying to update the Chef Server with the Deis Controller's 192 range IP so that rsyslog has the correct IP. Conflicts: Berksfile.lock Gemfile.lock
1 parent 17efd9d commit 28e395a

6 files changed

Lines changed: 52 additions & 40 deletions

File tree

Berksfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"locked_version": "2.2.2"
1111
},
1212
"deis": {
13-
"locked_version": "0.2.1",
13+
"locked_version": "0.1.2",
1414
"git": "https://github.com/opdemand/deis-cookbook.git",
15-
"ref": "617d5a2627fdee92ade9499b4a87c6ff85a99c66"
15+
"ref": "3277d069b61d261b6ebcab319041442fe38a2ae3"
1616
}
1717
}
1818
}

Gemfile.lock

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (3.2.15)
5-
i18n (~> 0.6, >= 0.6.4)
6-
multi_json (~> 1.0)
74
addressable (2.3.5)
85
akami (1.2.0)
96
gyoku (>= 0.4.0)
107
nokogiri (>= 1.4.0)
11-
berkshelf (2.0.10)
12-
activesupport (~> 3.2.0)
8+
berkshelf (3.0.0.beta3)
139
addressable (~> 2.3.4)
10+
buff-config (~> 0.2)
11+
buff-extensions (~> 0.4)
1412
buff-shell_out (~> 0.1)
15-
chozo (>= 0.6.1)
1613
faraday (>= 0.8.5)
1714
hashie (>= 2.0.2)
1815
minitar (~> 0.5.4)
19-
rbzip2 (~> 0.2.0)
2016
retryable (~> 1.3.3)
21-
ridley (~> 1.5.0)
22-
solve (>= 0.5.0)
17+
ridley (~> 1.6)
18+
solve (>= 0.8.0)
2319
thor (~> 0.18.0)
2420
buff-config (0.4.0)
2521
buff-extensions (~> 0.3)
@@ -30,11 +26,11 @@ GEM
3026
buff-shell_out (0.1.1)
3127
buff-ruby_engine (~> 0.1.0)
3228
builder (3.2.2)
33-
celluloid (0.14.1)
34-
timers (>= 1.0.0)
35-
celluloid-io (0.14.1)
36-
celluloid (>= 0.14.1)
37-
nio4r (>= 0.4.5)
29+
celluloid (0.15.2)
30+
timers (~> 1.1.0)
31+
celluloid-io (0.15.0)
32+
celluloid (>= 0.15.0)
33+
nio4r (>= 0.5.0)
3834
chef (11.6.2)
3935
erubis (~> 2.7)
4036
highline (~> 1.6, >= 1.6.9)
@@ -143,26 +139,24 @@ GEM
143139
rack (1.5.2)
144140
rash (0.4.0)
145141
hashie (~> 2.0.0)
146-
rbzip2 (0.2.0)
147142
rest-client (1.6.7)
148143
mime-types (>= 1.16)
149144
retryable (1.3.3)
150-
ridley (1.5.3)
145+
ridley (1.7.1)
151146
addressable
152147
buff-config (~> 0.2)
153148
buff-extensions (~> 0.3)
154149
buff-ignore (~> 1.1)
155150
buff-shell_out (~> 0.1)
156-
celluloid (~> 0.14.0)
157-
celluloid-io (~> 0.14.0)
151+
celluloid (~> 0.15)
152+
celluloid-io (~> 0.15)
158153
erubis
159154
faraday (>= 0.8.4)
160155
hashie (>= 2.0.2)
161156
json (>= 1.7.7)
162157
mixlib-authentication (>= 1.3.0)
163158
net-http-persistent (>= 2.8)
164159
net-ssh
165-
nio4r (>= 0.5.0)
166160
retryable
167161
solve (>= 0.4.4)
168162
varia_model (~> 0.1)

client/deis.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,12 +1775,8 @@ def providers_discover(self, args): # noqa
17751775
"whoami",
17761776
stderr=subprocess.PIPE
17771777
).strip()
1778-
ip = subprocess.check_output(
1779-
"/sbin/ifconfig | \
1780-
grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | \
1781-
grep -Eo '([0-9]*\.){3}[0-9]*' | \
1782-
grep -v '127.0.0.1' | \
1783-
head -n1",
1778+
hostname = subprocess.check_output(
1779+
"hostname",
17841780
stderr=subprocess.PIPE,
17851781
shell=True
17861782
).strip()
@@ -1789,7 +1785,7 @@ def providers_discover(self, args): # noqa
17891785
sys.exit(1)
17901786
creds = {
17911787
'user': user,
1792-
'ip': ip
1788+
'host': hostname + ".local"
17931789
}
17941790
body = {'creds': json.dumps(creds)}
17951791
sys.stdout.write('Activating Vagrant as a provider... ')

contrib/vagrant/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ you will need a running SSH server open on port 22.
6262
`service deis-server restart` and/or `service deis-worker restart` on the VM for your changes to instantly take effect.
6363
* It's worth having a read of `Vagrantfile.local.example`
6464

65-
7. If you want to hack on the command line client (`/client/deis.py`), install your local dev version rather than
65+
7. If you want to hack on the command line client (`client/deis.py`), install your local dev version rather than
6666
the one from Pip.
67-
* `cd deis && make install` This will symlink the dev version to your executables path.
67+
* `cd deis && make install` This installs the client into your executables path.
68+
* `sudo rm /usr/local/bin/deis && sudo ln ./deis.py /usr/local/bin/deis` This will symlink the dev version to your executables path.
6869
* Your deis controller is available at http://deis-controller.local so you can register with;
6970
`deis register http://deis-controller.local`
7071

contrib/vagrant/provision-controller.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ if [ ! -f /etc/ssh/sshd_config ] && [ ! -f /etc/sshd_config ]; then
2020
exit 1
2121
fi
2222

23+
# Make sure avahi-daemon is installed
24+
if ! which avahi-daemon > /dev/null; then
25+
echo 'Please install avahi-daemon to broadcast your hostname to the local network.'
26+
exit 1
27+
fi
28+
2329
#################
2430
# chef settings #
2531
#################
@@ -41,7 +47,7 @@ knife data bag create deis-apps 2>/dev/null
4147

4248
# Boot the deis-controller VM
4349
echo_color "Booting $node_name with 'vagrant up'"
44-
pushd $THIS_DIR
50+
pushd $THIS_DIR/../../
4551
vagrant up --provision
4652
if [ $? -gt 0 ]; then
4753
echo_color "Canceling provision because 'vagrant up' failed"
@@ -82,7 +88,6 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then #TODO: Might be nice to have flag to make manual
8288
fi
8389

8490
fi
85-
popd
8691

8792
echo_color "Provisioning $node_name with knife vagrant..."
8893
set -x
@@ -96,9 +101,25 @@ knife bootstrap "$node_name.local" \
96101
--sudo
97102
set +x
98103

99-
pushd $THIS_DIR/deis-controller
104+
# The IP address detected by Chef is the VM's eth0 10.0.0.0 range address.
105+
# However we need the 192 range address set on eth1.
106+
echo_color "Updating the IP address stored on the Chef Server for the Deis Controller node..."
107+
ipaddress=$(ping -c1 deis-controller.local | head -n1 | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
108+
knife exec -E "nodes.transform(\"name:deis-controller\") { \
109+
|n| n.normal_attrs[\"network\"][\"ipaddress\"] = "$ipaddress"; \
110+
n.save \
111+
}"
112+
if [ $? -eq 0 ]; then
113+
echo_color "IP address updated."
114+
fi
115+
100116
echo_color "Updating Django site object from 'example.com' to 'deis-controller'..."
101-
vagrant ssh -c "sudo su deis -c \"psql deis -c \\\"UPDATE django_site SET domain = 'deis-controller.local', name = 'deis-controller.local' WHERE id = 1 \\\"\"" >/dev/null
117+
vagrant ssh -c "sudo su deis -c \"psql deis -c \\\" \
118+
UPDATE django_site \
119+
SET domain = 'deis-controller.local', \
120+
name = 'deis-controller.local' \
121+
WHERE id = 1 \\\"\"" >/dev/null
122+
102123
if [ $? -eq 0 ]; then
103124
echo_color "Site object updated."
104125
fi

provider/vagrant.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def build_node(node):
7777
# Make a folder for the VM with its own Vagrantfile. Vagrant will then create a .vagrant folder
7878
# there too when it first gets booted.
7979
node_dir = HOST_NODES_DIR + '/' + uid
80-
mkdir = 'mkdir ' + node_dir
80+
mkdir = 'mkdir -p ' + node_dir
8181
cp_tpl = 'echo "' + result.replace('"', '\\"') + '" > ' + node_dir + '/Vagrantfile'
8282
_host_ssh(commands=[mkdir, cp_tpl], creds=node['creds'])
8383

@@ -155,15 +155,15 @@ def _host_ssh(creds={}, commands=[]):
155155
# TODO: Find a way of passing this error onto the CLI client.
156156
try:
157157
subprocess.check_call([
158-
'nc', '-z', '-w2', creds['ip'], '22'
158+
'nc', '-z', '-w2', creds['host'], '22'
159159
], stderr=subprocess.PIPE)
160160
except subprocess.CalledProcessError:
161-
raise RuntimeError("Couldn't ping port 22 at host with IP " + creds['ip'])
161+
raise RuntimeError("Couldn't ping port 22 at host with IP " + creds['host'])
162162

163-
ssh = connect_ssh(creds['user'], creds['ip'], 22, PKEY, timeout=120)
163+
ssh = connect_ssh(creds['user'], creds['host'], 22, PKEY, timeout=120)
164164
result, status = exec_ssh(ssh, command)
165165
if status > 0:
166166
raise RuntimeError(
167-
'SSH to Vagrant host error: ' + result +
168-
'Command: ' + command)
167+
'SSH to Vagrant host error: ' + result.decode('utf-8') +
168+
'Command: ' + command.decode('utf-8'))
169169
return result

0 commit comments

Comments
 (0)