Merge "Improve launch-node deps and fix script bugs"

This commit is contained in:
Zuul 2022-11-30 17:50:59 +00:00 committed by Gerrit Code Review
commit 6ba92c3a52
2 changed files with 23 additions and 15 deletions

View File

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

View File

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