From cdf5b8056ed177d400ca01e0b6c5f908f8873d33 Mon Sep 17 00:00:00 2001 From: Eesaan Atluri <eesaanatluri@gmail.com> Date: Tue, 16 Aug 2022 02:32:48 -0500 Subject: [PATCH] Add ansible prov for OOD2.x roles. - Set build_instance_name to match the hosts defined in OOD play - Currently, use_proxy defaults to true for all connection types. In the future, this option will be changed to default to false for SSH and WinRM connections where the provisioner has access to a host IP. Further details in documentation https://www.packer.io/plugins/provisioners/ansible/ansible#use_proxy - As stated in docs link above use_proxy will be set to false in the future ansible versions. Currently we set it to False. Provide a valid username & ssh key to the ansible provisioner directly or make sure that username and ssh key being used by ssh communicator will work for your needs. We chose option 2. --- openstack/nodeimage.pkr.hcl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openstack/nodeimage.pkr.hcl b/openstack/nodeimage.pkr.hcl index 5e4a245..c02d853 100644 --- a/openstack/nodeimage.pkr.hcl +++ b/openstack/nodeimage.pkr.hcl @@ -6,12 +6,16 @@ source "openstack" "image" { image_name = local.local_image_name source_image_name = var.source_image flavor = var.flavor + instance_name = var.build_instance_name floating_ip_network = var.floating_ip_network networks = var.networks security_groups = var.security_groups ssh_username = var.ssh_username + ssh_keypair_name = var.ssh_keypair_name + ssh_private_key_file = var.ssh_private_key_file + } build { @@ -24,4 +28,18 @@ build { "--extra-vars", "root_ssh_key='${var.root_ssh_key}'" ] } + provisioner "ansible" { + use_proxy = false + ssh_authorized_key_file = "/home/ubuntu/.ssh/id_rsa.pub" + ansible_env_vars = ["ANSIBLE_HOST_KEY_CHECKING=False"] + playbook_file = "../CRI_XCBC/ood-packer.yaml" + roles_path = "./ansible/roles" + inventory_file = "../CRI_XCBC/hosts" + extra_arguments = [ + "--extra-vars", "root_ssh_key='${var.root_ssh_key}'", + "--private-key=${var.ssh_private_key_file}", + "--user=centos", + #"-vvvv" + ] + } } -- GitLab