61 Commits

Author SHA1 Message Date
Jenkins
44f909dc7c Merge "launch: add puppet environment option" 2016-09-16 01:21:15 +00:00
Jenkins
f2ac215342 Merge "launch: stream syslog on remote host" 2016-09-16 00:23:09 +00:00
James E. Blair
e8da64fa94 launch: add puppet environment option
Change-Id: I3e0ce41e399cc5e3fdb8153e5bac5b97fd58f0e1
Depends-On: I1c0b25a838b6fef6487fc3a8e5b78b73a3ae305a
2016-09-15 15:53:08 -07:00
James E. Blair
ccfe5111c8 launch: stream syslog on remote host
So that operators have a clue what's going on during the long
initial puppet run.

Change-Id: If310c3420d942c79c8b04d3e9ce68f39081cc507
2016-09-15 15:46:33 -07:00
Jenkins
2d0f60a3dd Merge "launch: Use popen rather than check_output" 2016-09-15 22:41:30 +00:00
James E. Blair
334715f12a launch: Use popen rather than check_output
This way we are able to stream the output from commands as they
are received for better debugging.  We can also move some new
debug statements to inside of the new run() function so they
are more automatic.

Change-Id: I484f5cf70aa15923ea4bb866f3be536b2e8ed4ed
2016-09-15 15:17:50 -07:00
Ian Wienand
20afe1a62f launch-node.py: More verbose logging
One problem with "shell script as python" is that there's no
equivalent of "-x" in shell, which makes it really hard to extract
what's being called and where output came from.

This adds a bit more verbose logging around the ssh calls to try and
help someone parsing the logs.

Change-Id: I85e2415b47e044cfa1c678fc7786b4891fa1f93e
2016-08-24 11:06:57 +10:00
Ian Wienand
4ac715e0f3 launch-node.py: set ansible log path
Avoid a bunch of warnings about unwritable /var/log/ansible.log (the
default) by setting the log path environment variable where we call
ansible.

Note expand-groups.sh is moved inside the JobDir() context so we can
use the environment var there too, as it calls ansible underneath.

Change-Id: I575d633a36db8cfb891c8903a7bfbea73a4cfb29
2016-08-24 11:06:04 +10:00
Ian Wienand
ab376eac7a launch-node.py: save key when failing early
Save the key to a file in /tmp when failing early with --keep.
Although it is put into the JobDir later, if we fail before that we're
locked out of the host.

While we're here, make what just happened in an error case a little
clearer

Change-Id: Ide601e2018302664bc4ad609c4483aa1451b3724
2016-08-24 11:04:45 +10:00
Ian Wienand
4ed43d2754 launch-node.py: restart interface
RAX nodes are exhibiting new behaviour of having ipv6 configured but
not active.  Restart eth0 to pick up the address in
/etc/network/interfaces so the ping6's work

Change-Id: I6b60bde34cc28ca60c5cbbb41de02cd89354cc32
2016-08-24 06:33:06 +10:00
Jenkins
3addf0b5a9 Merge "Correct launch-node.py --config-drive default" 2016-07-08 08:12:37 +00:00
Monty Taylor
3b9eda9359
Prevent launch-node from breaking generated groups
There are potentially two related issues here which can result in
an empty generated groups file. The first is that if there are OS_
environment variables set, then os-client-config can create an 'environ'
cloud. That cloud then, in most cases here, will not be a valid cloud
since it won't be a full config, so iterating over all existing clouds
to get their server will fail, meaning that the inventory will be empty
meaning that generated groups will then be generated empty.

To deal with that, we can consume the newer upstream option that allows
the inventory to not bail out if it has a bad cloud, but instead get all
of the resources from the clouds that do work.

Additionally though, we can do an explicit inventory run so that we can
look to see if the inventory run failed, and if so, avoid running the
expand-groups.sh script, since we'd be fairly assured that it would be
running on top of a bad inventory cache.

Change-Id: Ib18987b3083f6addc61934b435d7ecb14aa1d25a
2016-07-07 11:21:14 -05:00
Jeremy Stanley
d66b8f47c4 Correct launch-node.py --config-drive default
For --config-drive to actually work as advertised in launch-node.py,
it needs to default to False. Otherwise this option is useless.

Change-Id: Ib29fa758779e89d3d25399615fd009b836dda598
2016-07-07 15:04:53 +00:00
James E. Blair
df81542135 Use global generated groups in launch-node
When launching a server, ansible needs to know what groups the
new host is in so that it can copy the appropriate files.  Figuring
that out is done based on the groups.txt file and the expand-groups
script.  This change runs that script after creating a host, which
will update the global list of expanded groups.  That is then
symlinked into a temporary inventory directory used by launch-node.

The JobDir concept is borrowed from Zuul as a simple way of creating
and deleting at the appropriate time a complex temporary directory.

Change-Id: Icce083ca67a3473b7d77401142f870fd28dd08f5
2016-06-09 09:23:32 -07:00
Clark Boylan
ba4429022b Properly handle volumes in launch node
We can only get the volume attach device if we are attaching a volume.
Check if the volume is being attached and only determine the attachment
location in that case to avoid errors.

Story: 2000569
Change-Id: I4adc5e23abdfc0627a0850f845e2333d3bd25e63
2016-05-02 15:04:57 -07:00
Clark Boylan
6429922e99 Add support to launch-node for cinder attach
Now that we have a shade version of the launch node script adding in
support for attaching a cinder volume is simple. Do this so that
launching mirrors which rely on cinder volumes is simpler.

This updates the mount_volume.sh script to setup the first cinder volume
with lvm and mount it under the specified path. It will also install
lvm2 pacakges since they may not be present on all base images.

This updates the make_swap.sh script to avoid blindly using /dev/vdb as
the location for swap as this may be a cinder volume or config drive.

We add availability zone, device specification, mount path, and
fs label support to shade-launch-node.py as these are all necessary
inputs to properly mount a cinder volume in a VM.

Change-Id: Ie95fd4bd5fca8df4f8046d43d1333935cad567e3
2016-04-19 11:07:23 -07:00
Monty Taylor
453051aafb Don't pass OS_CLOUD and OS_REGION_NAME to expand-groups
There is a bug in OCC that causes an envvars cloud to be created when
the only two env vars are the selectors OS_CLOUD and OS_REGION_NAME. So
exclude them from the envionment when running the group creation
command.

Also, there is a bug in the invocation of the hostname playbook, in that
it was passing in the UUID as the target to run against, but we're
writing out a name-based inventory.

Change-Id: I0b524dc43ec96c6645ae82a090744eab463e7fb9
2016-03-22 19:33:42 -05:00
Paul Belanger
72e045ea16 Give 0775 to launch-node.py
Change-Id: If56ca023c6a30735a18c891c6603424c718aeb67
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-03-22 23:59:42 +00:00
Monty Taylor
9e678eeb8e Don't set the host's name as UUID
It looks like we solved the duplicate server problem twice in
conflicting ways. Using uuid in the inventory is not needed, bcause
we're making a specific inventory for the ansible commands and avoiding
the OpenStack inventory. So the ansible run has no idea of any other
servers other than the one we're making right now. With that, we can use
name as the hostname rather than UUID.

Story: 2000520
Change-Id: Idb967e10fc00471923077e4e9caa32fdb4c1cc78
2016-03-22 12:16:10 -05:00
Monty Taylor
3eb4a5a66a Use set-hostnames playbook in launch-node
We have a playbook that does the logic of setting the hostname. Rather
than implementing that logic in launch-node - just use the playbook.

Change-Id: I1a6c0ff12803bdac35631cb3bb2c8fe70cbd1904
2016-03-10 09:48:34 +01:00
Monty Taylor
cdead64021 Zero out the inventory cache instead of removing it
https://github.com/ansible/ansible/pull/14882 landed, so the inventory
will understand that an empty cache means the inventory needs
refetching. Zero out the file, and start consuming inventory from the
master branch of ansible since mordred controls that file anyway.

Change-Id: I2a4f4b21c50bfa94a229dd109e3d21f47552f0a1
2016-03-09 14:23:54 -06:00
Monty Taylor
f94594a98e Retire old launch-node.py
It has served us well, but it's time for the new world order to take
over.

Change-Id: I72a9f1b1c0f1bd331b5f862f5f69966950ffe963
2016-03-09 14:23:54 -06:00
Monty Taylor
7699226007 Add script to make ansible groups from patterns
We have a set of hostname patterns which is not a thing that ansible
supports in inventory files. While we can put hostname patterns into
playbooks directly, that does not help us with copying hiera group files
since ansible doesn't know about the groups in site.pp and puppet
doesn't know about the ansible groups.

Instead, do a quick expansion any time the groups.txt file changes and
at the end of launch-node. It will be left to admins to run
expand-groups.sh whenever they delete a node.

Change-Id: I00c60748ddb2d35a3b98f78d828dabebcf065118
2016-01-15 12:13:00 -05:00
Monty Taylor
b23025acaa Fix three nits
These were caught in earlier reviews.

Change-Id: I026678fbbe871ffb138fd2c0dba9e788457da3a0
2015-11-30 22:24:53 -06:00
Monty Taylor
714c934d0c Use OpenStack for inventory instead of puppet
With the puppetmaster not there anymore, we should consume inventory
from OpenStack rather than from puppet.

It turns out that because of the way static and dynamic inventories get
merged, the static file needs to stand alone. SO - if you need to
disable a dynamic host from OpenStack (pretty much all of our hosts) you
need to not only add it to dynamic:children, you need to add an emtpy
group into the static file too, otherwise you'll get an error like:

 root@puppetmaster:~# ansible -i newinv '!disabled' --list-hosts
 ERROR: newinv/static:4: child group is not defined: (jenkins-dev.openstack.org)

Change-Id: Ic6809ed0b7014d7aebd414bf3a342e3a37eb10b6
2015-11-30 22:02:41 -06:00
James E. Blair
747d832dd5 Disable volume option until it is cinderified.
Change-Id: I82597ef84785a570b37bfc0b5e24c129d9a3b3b9
2015-09-17 10:56:34 -07:00
James E. Blair
3fc24b6b7f Add support for 'admin' user for OVH
OVH images have, of course, yet another 'root' user they would like
us to use instead of root.

Change-Id: If8cc3d31862e352eed40fc041a4c6c695a35063a
2015-09-16 10:32:17 -07:00
James E. Blair
7eab5a6f12 Make OS_SERVICE_NAME optional in launch-node
This parameter is usually not necessary, and over-specifying it
can be problematic because the value is not consistent.

Change-Id: I0a90631499294e7a6eb287f24739cf4884a8db7b
2015-09-16 10:08:02 -07:00
Clark Boylan
871cefc65f Handle ssh failures with reboot in launch-node.py
New systemd based distros reboot so quickly that the ssh connection
errors returning 255 (or -1 in python because signed integers). Ignore
return codes of -1 when rebooting over ssh as a result. All other return
codes will be propogated properly.

Change-Id: I272f00e9e07f1ed04f2b97d0e1609c6e8d49caf3
2015-08-28 16:30:39 -07:00
James E. Blair
0f4690f04b Add support for boot from volume to launch-node
This is needed for rax compute and io flavors.

Change-Id: I20a6d7161a62e28c47031041d6e42b25d304fc46
2015-06-19 17:29:00 -07:00
Monty Taylor
faadc45a1e Set default base OS to Trusty in launch-node
If we're going to spin up a new node, it should be Trusty unless we
think more about it.

Change-Id: Id3580d8e04214dc9a80adbcba86cc1ef6523e472
2015-05-02 09:19:24 -04:00
Monty Taylor
7b761f4148 Pass in service name to nova constructor.
Because, you know, we should have to do this.

Rackspace publishes two things called "compute" into their catalog for
customers who still have the old compute service.

Change-Id: I27d5a78fc743057a270acd4bf7c85fd998f9074d
2015-02-26 16:30:13 -05:00
Jeremy Stanley
2f3127c458 Allow nonzero puppet exit codes when launching
* launch/launch-node.py: Now that we're using --detailed-exit-codes
with puppet, we should not abort when the ssh call exits nonzero.
Puppet explicitly returns nonzero codes which indicate success
conditions, and we already have a function in place to interpret
them.

Change-Id: If66d345902d05fa0898d202f5f71c087df9f4ce7
2014-10-25 00:48:36 +00:00
Ian Wienand
11c08e0055 Login with 'centos' user for node launch
HP Cloud centos7 images are currently failing with 'Please login as
the user "centos" rather than the user "root"'.

This adds the 'centos' user as one of the logins to try, and adds a
little documentation to the subsequent fixup of the authorized_keys
file

Change-Id: I46b62c8c4aed7a1c9522d60db7f726ebcb30281c
2014-10-24 08:25:27 +11:00
Jenkins
d2254995b3 Merge "Improve network support in launch-node.py" 2014-10-23 19:31:48 +00:00
Monty Taylor
7a4e51d65e Add detailed-exitcodes to launch_node
We've got the logic elsewhere to properly deal with puppet bizarre exit
code strategy. Put it in launch_node too.

Change-Id: I4a414a27b58b2d4d890020f4b2aaed50f7c8f26b
2014-10-23 01:35:15 +00:00
Dmitry Teselkin
4c7c93252d Improve network support in launch-node.py
Currently launch-node.py doesn't allow to specify network label
and floating IP pool name, using the defaults from nova-network.

This patch allows to specify network label to attach instance to,
and floating IP pool from which floating IPs could be assigned.

Change-Id: I46024bc1c217f99f19717aeb04d424a01440203a
2014-10-20 17:55:11 +04:00
Jeremy Stanley
6b9a27a90f Use the current Puppet master when launching
Change-Id: Ia5f5320aa77791c6c03b42b395945132e699f57e
2014-09-15 20:48:33 +00:00
James E. Blair
e6775bd7b5 Fix variable ref error in launch node
The new code to create volumes incorrectly affects the non-volume
case due to an indentation bug.  This corrects that.

Change-Id: I18eb1222447393e769fbbbf550407bf103b11e99
2014-09-10 10:37:09 -07:00
Monty Taylor
4ed7c43aa4 Add option to keep failed server
This can be useful when debugging.

Change-Id: Iaa1775ad3ba6cfd088ce3764e502019f611dde67
2014-09-05 18:05:29 +00:00
Clark Boylan
f490260de7 Add support to launch node for attaching volumes
We are using cinder block devices more and more. Update launch node so
that it can attach a preexisting cinder volume against a new nova server
on first boot. This will allow puppet or other config management to
format and mount that block device into the VMs filesystem.

Change-Id: Ic121cdc06dcbea0e38e8d0ff8946e999af3d727e
2014-09-05 18:05:23 +00:00
Nicolas Simonds
d795d7f6fb launch-node.py: request flavors/images by ID or name
It is deemed useful by some to pass IDs rather than names to
launch-node.py for flavors and images; mostly due to the fact that
names are not unique, and the "first-matched" behavior on names
means that it can end up doing the wrong thing in certain cases.

Change-Id: Ief89174fedac7921f85bbfe3a456059ecc0f19bf
2014-08-06 11:08:28 -07:00
Monty Taylor
0fb121893d Remove salt
We don't really use the salt infrastructure that we set up, which means
it's cruft. Go ahead and admit that we don't use it and remove it from
our systems.

Change-Id: Ic43695719cbad30aded16ac480deb3dfd9b2a110
2014-07-04 21:44:44 -07:00
Jeremy Stanley
2994931fd4 Update launch script and instructions
* launch/README: Correct outdated references to salt and puppet
certs. Modernize the recommended image name.

* launch/launch-node.py: When run as root, keep the puppet group on
private keys so that they're readable by puppet group members. That
way it won't break subsequent runs as non-root following the current
instructions in the README file. Modernize the default image name.

Change-Id: Ic5034121d4d0df3c096c2e474a9d3d41ec361021
2014-06-04 16:05:46 +00:00
Jenkins
5424d7aca7 Merge "Adds insecure option to launch_node.py" 2014-05-01 21:35:18 +00:00
Philip Schwartz
7590fa4e29 Adds insecure option to launch_node.py
Added the abillity to use launch_node.py to connect to and create 
infrastructure instances in openstack setups that are not setup to use 
the ssl secured clients.

This matches the functionality of the nova cli to accept NOVACLIENT_INSECURE.

Change-Id: Ibfb5bb4665f36a155ec488c475e03f9cd901e9d6
Signed-off-by: Philip Schwartz <philip.schwartz@rackspace.com>
2014-04-30 18:42:32 +00:00
James E. Blair
2c8d19ab08 Create a swap partition if needed for new servers
Add a script to  handle cloud servers with no swap. This can be
used before install_puppet when developers run it by hand, and
is called directly by launch_node. If the host has
no swap, create a swap partition from the ephemeral disk and use
the remainder on /opt.

Change-Id: Iac8bfe4924d8607ddbddc45312a51fe52eb4cdbc
2014-04-23 15:44:06 -07:00
James E. Blair
8797736821 Support launching rax performance nodes
And recommend them.

Change-Id: I2a45ef250378604aba72b74b170cec127b18d1be
2013-12-18 20:03:09 +00:00
Monty Taylor
eef4f76011 Clean up flake8 issues before switch
In anticipation of swtiching to flake8 as part of the removal of
pyflakes jobs, clean up a few flake8 errors so that we don't have to
ignore as many things.

Change-Id: Idb8466bb3194904d84e17dd3f2a7c32aff13788c
2013-09-20 14:37:30 -07:00
Robert Collins
49b0b0c78d Make third-party imports clearer in launch/.
This is a minor step towards PEP-8 as well, but mainly makes it easier
to document what third party modules are needed.

Change-Id: Id901ef437fcdeb11c8dd555e8db7c13daa86c4b2
2013-08-31 09:54:09 +12:00