Improve launch-node deps and fix script bugs

The version of python-cinderclient needs to be constrained to before
the point at which it dropped volume API v2 support (which happened
in 8.0.0). If this is pinned back, latest openstackclient can be
installed and used for Rackspace volume operations without issue.
Make sure we install new enough OpenStackSDK so it doesn't try to
pass unsupported networking options in server create calls to
Rackspace too.

The script itself had a couple of issues once rehomed, the first
being it was looking for Ansible playbooks relative to its former
path in the repository rather than its installed location in the
venv, so make that path configurable but have it default to the
absolute path to those on the bridge now. Also, the script really
wanted to clear the ansible cache, but when that path doesn't exist
(as is currently the case on the bridge), it aborts rather than
continuing, so wrap that call in a try/except.

While we're here, update our default server image from focal to
jammy.

Change-Id: I103c7799ebe319d2d8b3fb626d7804387d3e8a60
This commit is contained in:
Jeremy Stanley 2022-11-22 18:22:56 +00:00
parent b879e5fad7
commit a31bd1a8fd
2 changed files with 23 additions and 15 deletions

View File

@ -14,11 +14,11 @@ classifiers = [
]
dependencies = [
"paramiko>=2.9.1",
# This is a very specific list which is known to work
# with RAX storage...
"python-openstackclient==4.0.2",
"python-cinderclient==9.1.0",
"openstacksdk==0.102.0"
"python-openstackclient",
# Minimum to work with clouds like RAX that don't take network:auto
"openstacksdk>=0.103",
# Pin to a version of cinderclient known to work with RAX storage...
"python-cinderclient<8",
]
[project.urls]

View File

@ -96,7 +96,8 @@ def stream_syslog(ssh_client):
def bootstrap_server(server, key, name, volume_device, keep,
mount_path, fs_label, environment, timeout, ignore_ipv6):
mount_path, fs_label, environment, timeout, ignore_ipv6,
playbooks):
ip = server.public_v4
ssh_kwargs = dict(pkey=key)
@ -156,8 +157,11 @@ def bootstrap_server(server, key, name, volume_device, keep,
# Zero the ansible inventory cache so that next run finds the new server
inventory_cache_dir = '/var/cache/ansible/inventory'
try:
for inventory_cache in os.listdir(inventory_cache_dir):
os.unlink(os.path.join(inventory_cache_dir, inventory_cache))
except FileNotFoundError:
pass
with JobDir(keep) as jobdir:
# Update the generated-groups file globally and incorporate it
@ -211,8 +215,7 @@ def bootstrap_server(server, key, name, volume_device, keep,
'base.yaml',
'apply-package-updates.yaml',
]:
run(ansible_cmd + [
os.path.join(SCRIPT_DIR, '..', 'playbooks', playbook)],
run(ansible_cmd + [os.path.join(playbooks, playbook)],
env=jobdir.env)
try:
@ -229,7 +232,7 @@ def bootstrap_server(server, key, name, volume_device, keep,
def build_server(cloud, name, image, flavor,
volume, keep, network, boot_from_volume, config_drive,
mount_path, fs_label, availability_zone, environment,
volume_size, timeout, ignore_ipv6):
volume_size, timeout, ignore_ipv6, playbooks):
key = None
server = None
@ -275,7 +278,8 @@ def build_server(cloud, name, image, flavor,
else:
volume_device = None
bootstrap_server(server, key, name, volume_device, keep,
mount_path, fs_label, environment, timeout, ignore_ipv6)
mount_path, fs_label, environment, timeout,
ignore_ipv6, playbooks)
print('UUID=%s\nIPV4=%s\nIPV6=%s\n' % (
server.id, server.public_v4, server.public_v6))
except Exception:
@ -322,7 +326,7 @@ def main():
parser.add_argument("--flavor", dest="flavor", default='1GB',
help="name (or substring) of flavor")
parser.add_argument("--image", dest="image",
default="Ubuntu 20.04 LTS (Focal Fossa) (Cloud)",
default="Ubuntu 22.04 LTS (Jammy Jellyfish) (Cloud)",
help="image name")
parser.add_argument("--environment", dest="environment",
help="Puppet environment to use",
@ -362,9 +366,12 @@ def main():
parser.add_argument("--ignore_ipv6", dest="ignore_ipv6",
help="Ignore IPv6 addresses from API",
action='store_true', default=False)
parser.add_argument("--az", dest="availability_zone", default=None,
help="AZ to boot in.")
parser.add_argument("--playbooks", dest="playbooks",
default="/home/zuul/src/opendev.org/opendev/"
"system-config/playbooks",
help="alternative playbook directory")
options = parser.parse_args()
openstack.enable_logging(debug=options.verbose)
@ -407,7 +414,8 @@ def main():
options.mount_path, options.fs_label,
options.availability_zone,
options.environment, options.volume_size,
options.timeout, options.ignore_ipv6)
options.timeout, options.ignore_ipv6,
options.playbooks)
dns.print_dns(cloud, server)
print("If this is a server that is expected to send email (ask, review,")
print("lists, etc) double check that the server's IPs are not listed on")