From e8da64fa94067b05e1fd2f0a435f8dd81132059c Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 15 Sep 2016 15:26:44 -0700 Subject: [PATCH] launch: add puppet environment option Change-Id: I3e0ce41e399cc5e3fdb8153e5bac5b97fd58f0e1 Depends-On: I1c0b25a838b6fef6487fc3a8e5b78b73a3ae305a --- launch/launch-node.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/launch/launch-node.py b/launch/launch-node.py index c328c4cfc4..17fd765b9f 100755 --- a/launch/launch-node.py +++ b/launch/launch-node.py @@ -94,7 +94,7 @@ def stream_syslog(ssh_client): def bootstrap_server(server, key, name, volume_device, keep, - mount_path, fs_label): + mount_path, fs_label, environment): ip = server.public_v4 ssh_kwargs = dict(pkey=key) @@ -199,6 +199,10 @@ def bootstrap_server(server, key, name, volume_device, keep, '-e', 'target={name}'.format(name=name), ] + if environment is not None: + ansible_cmd += [ + '-e', + 'puppet_environment={env}'.format(env=environment)] # Run the remote puppet apply playbook limited to just this server # we just created for playbook in [ @@ -221,7 +225,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): + mount_path, fs_label, availability_zone, environment): key = None server = None @@ -264,7 +268,7 @@ def build_server(cloud, name, image, flavor, else: volume_device = None bootstrap_server(server, key, name, volume_device, keep, - mount_path, fs_label) + mount_path, fs_label, environment) print('UUID=%s\nIPV4=%s\nIPV6=%s\n' % ( server.id, server.public_v4, server.public_v6)) except Exception: @@ -306,6 +310,9 @@ def main(): parser.add_argument("--image", dest="image", default="Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)", help="image name") + parser.add_argument("--environment", dest="environment", + help="Puppet environment to use", + default=None) parser.add_argument("--volume", dest="volume", help="UUID of volume to attach to the new server.", default=None) @@ -369,7 +376,8 @@ def main(): options.network, options.boot_from_volume, options.config_drive, options.mount_path, options.fs_label, - options.availability_zone) + options.availability_zone, + options.environment) dns.print_dns(cloud, server) if __name__ == '__main__':