Ansible with Terraform's Null Resource (Provider)
In this post, we use Terraform to call Ansible. Terraform is a great infrastructure provisioning tool, but as we already know it doesn't come with a config management system. That's where Ansible comes in. We use Terraform to stand up aws cloud instances, and then we hand over the reins to Ansible to finish up the configuration.
Basically, what we do in this post:
$ terraform init $ terraform plan $ terraform apply $ terraform destroy
Actually, we run ansible-playbook -i hosts play.yml
within provisioner of local-exec via null_resource.
Repo: Using-Ansible-with-Terraform
Ansible and Terraform should be installed.
For Terraform to work for AWS, set the following env variables:
$ export AWS_ACCESS_KEY_ID="access_key_id" $ export AWS_SECRET_ACCESS_KEY="secret_access_key"
If we need to run provisioners that aren't directly associated with a specific resource, we can associate them with a null_resource.
The null_resource implements the standard resource lifecycle but takes no further action.
Here is the snippet of main.tf:
resource "null_resource" "ConfigureAnsibleLabelVariable" { provisioner "local-exec" { command = "echo [${var.dev_host_label}:vars] > hosts" } provisioner "local-exec" { command = "echo ansible_ssh_user=${var.ssh_user_name} >> hosts" } provisioner "local-exec" { command = "echo ansible_ssh_private_key_file=${var.ssh_key_path} >> hosts" } provisioner "local-exec" { command = "echo [${var.dev_host_label}] >> hosts" } } resource "null_resource" "ProvisionRemoteHostsIpToAnsibleHosts" { count = "${var.instance_count}" connection { type = "ssh" user = "${var.ssh_user_name}" host = "${element(aws_instance.myInstanceAWS.*.public_ip, count.index)}" private_key = "${file("${var.ssh_key_path}")}" } provisioner "remote-exec" { inline = [ "sudo yum update -y", "sudo yum install python-setuptools python-pip -y", "sudo pip install httplib2" ] } provisioner "local-exec" { command = "echo ${element(aws_instance.myInstanceAWS.*.public_ip, count.index)} >> hosts" } }
Here is the hosts file created by the local-exec provisioner of the null_resource:
[terra_ansible_host:vars] ansible_ssh_user=ec2-user ansible_ssh_private_key_file=~/.ssh/khong-aol.pem [terra_ansible_host] 3.86.198.164
The local-exec provisioner invokes a local executable after a resource is created. This invokes a process on the machine running Terraform, not on the resource.
The remote-exec provisioner invokes a script on a remote resource after it is created. This can be used to run a configuration management tool, bootstrap into a cluster, etc.
For more details on the provisioners, check Terraform: Provisioners.
$ terraform init Initializing provider plugins... The following providers do not have any version constraints in configuration, so the latest version was installed. To prevent automatic upgrades to new major versions that may contain breaking changes, it is recommended to add version = "..." constraints to the corresponding provider blocks in configuration, with the constraint strings suggested below. * provider.aws: version = "~> 2.20" * provider.null: version = "~> 2.1" Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.
$ terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. ------------------------------------------------------------------------ An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: + aws_instance.myInstanceAWS id: <computed> ami: "ami-0c6b1d09930fac512" arn: <computed> associate_public_ip_address: <computed> availability_zone: <computed> cpu_core_count: <computed> cpu_threads_per_core: <computed> ebs_block_device.#: <computed> ephemeral_block_device.#: <computed> get_password_data: "false" host_id: <computed> instance_state: <computed> instance_type: "t2.micro" ipv6_address_count: <computed> ipv6_addresses.#: <computed> key_name: "khong-aol" network_interface.#: <computed> network_interface_id: <computed> password_data: <computed> placement_group: <computed> primary_network_interface_id: <computed> private_dns: <computed> private_ip: <computed> public_dns: <computed> public_ip: <computed> root_block_device.#: <computed> security_groups.#: <computed> source_dest_check: "true" subnet_id: "subnet-e03d78ce" tags.%: "1" tags.Name: "terra-ansible" tenancy: <computed> volume_tags.%: <computed> vpc_security_group_ids.#: <computed> + null_resource.ConfigureAnsibleLabelVariable id: <computed> + null_resource.ModifyApplyAnsiblePlayBook id: <computed> + null_resource.ProvisionRemoteHostsIpToAnsibleHosts id: <computed> Plan: 4 to add, 0 to change, 0 to destroy. ------------------------------------------------------------------------ Note: You didn't specify an "-out" parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if "terraform apply" is subsequently run.
$ terraform apply An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: + aws_instance.myInstanceAWS id: <computed> ami: "ami-0c6b1d09930fac512" arn: <computed> associate_public_ip_address: <computed> availability_zone: <computed> cpu_core_count: <computed> cpu_threads_per_core: <computed> ebs_block_device.#: <computed> ephemeral_block_device.#: <computed> get_password_data: "false" host_id: <computed> instance_state: <computed> instance_type: "t2.micro" ipv6_address_count: <computed> ipv6_addresses.#: <computed> key_name: "khong-aol" network_interface.#: <computed> network_interface_id: <computed> password_data: <computed> placement_group: <computed> primary_network_interface_id: <computed> private_dns: <computed> private_ip: <computed> public_dns: <computed> public_ip: <computed> root_block_device.#: <computed> security_groups.#: <computed> source_dest_check: "true" subnet_id: "subnet-e03d78ce" tags.%: "1" tags.Name: "terra-ansible" tenancy: <computed> volume_tags.%: <computed> vpc_security_group_ids.#: <computed> + null_resource.ConfigureAnsibleLabelVariable id: <computed> + null_resource.ModifyApplyAnsiblePlayBook id: <computed> + null_resource.ProvisionRemoteHostsIpToAnsibleHosts id: <computed> Plan: 4 to add, 0 to change, 0 to destroy. Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes null_resource.ConfigureAnsibleLabelVariable: Creating... null_resource.ConfigureAnsibleLabelVariable: Provisioning with 'local-exec'... null_resource.ConfigureAnsibleLabelVariable (local-exec): Executing: ["/bin/sh" "-c" "echo [terra_ansible_host:vars] > hosts"] null_resource.ConfigureAnsibleLabelVariable: Provisioning with 'local-exec'... null_resource.ConfigureAnsibleLabelVariable (local-exec): Executing: ["/bin/sh" "-c" "echo ansible_ssh_user=ec2-user >> hosts"] null_resource.ConfigureAnsibleLabelVariable: Provisioning with 'local-exec'... null_resource.ConfigureAnsibleLabelVariable (local-exec): Executing: ["/bin/sh" "-c" "echo ansible_ssh_private_key_file=~/.ssh/khong-aol.pem >> hosts"] null_resource.ConfigureAnsibleLabelVariable: Provisioning with 'local-exec'... null_resource.ConfigureAnsibleLabelVariable (local-exec): Executing: ["/bin/sh" "-c" "echo [terra_ansible_host] >> hosts"] null_resource.ConfigureAnsibleLabelVariable: Creation complete after 0s (ID: 5076260706150615561) aws_instance.myInstanceAWS: Creating... ami: "" => "ami-0c6b1d09930fac512" arn: "" => "<computed>" associate_public_ip_address: "" => "<computed>" availability_zone: "" => "<computed>" cpu_core_count: "" => "<computed>" cpu_threads_per_core: "" => "<computed>" ebs_block_device.#: "" => "<computed>" ephemeral_block_device.#: "" => "<computed>" get_password_data: "" => "false" host_id: "" => "<computed>" instance_state: "" => "<computed>" instance_type: "" => "t2.micro" ipv6_address_count: "" => "<computed>" ipv6_addresses.#: "" => "<computed>" key_name: "" => "khong-aol" network_interface.#: "" => "<computed>" network_interface_id: "" => "<computed>" password_data: "" => "<computed>" placement_group: "" => "<computed>" primary_network_interface_id: "" => "<computed>" private_dns: "" => "<computed>" private_ip: "" => "<computed>" public_dns: "" => "<computed>" public_ip: "" => "<computed>" root_block_device.#: "" => "<computed>" security_groups.#: "" => "<computed>" source_dest_check: "" => "true" subnet_id: "" => "subnet-e03d78ce" tags.%: "" => "1" tags.Name: "" => "terra-ansible" tenancy: "" => "<computed>" volume_tags.%: "" => "<computed>" vpc_security_group_ids.#: "" => "<computed>" aws_instance.myInstanceAWS: Still creating... (10s elapsed) aws_instance.myInstanceAWS: Still creating... (20s elapsed) aws_instance.myInstanceAWS: Still creating... (30s elapsed) aws_instance.myInstanceAWS: Creation complete after 37s (ID: i-0de203fa9e9766ae1) null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Creating... null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Provisioning with 'remote-exec'... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Connecting to remote host via SSH... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Host: 3.86.198.164 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): User: ec2-user null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Password: false null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Private key: true null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): SSH Agent: true null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Checking Host Key: false null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Connecting to remote host via SSH... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Host: 3.86.198.164 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): User: ec2-user null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Password: false null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Private key: true null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): SSH Agent: true null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Checking Host Key: false null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Connecting to remote host via SSH... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Host: 3.86.198.164 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): User: ec2-user null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Password: false null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Private key: true null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): SSH Agent: true null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Checking Host Key: false null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Connected! null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Loaded plugins: extras_suggestions, null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): : langpacks, priorities, null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): : update-motd null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Existing lock /var/run/yum.pid: another copy is running as pid 3303. null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Another app is currently holding the yum lock; waiting for it to exit... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): The other application is: yum null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Memory : 101 M RSS (392 MB VSZ) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Started: Sun Jul 21 18:56:19 2019 - 00:07 ago null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): State : Running, pid: 3303 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Existing lock /var/run/yum.pid: another copy is running as pid 3315. null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Another app is currently holding the yum lock; waiting for it to exit... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): The other application is: yum null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Memory : 79 M RSS (298 MB VSZ) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Started: Sun Jul 21 18:56:19 2019 - 00:09 ago null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): State : Running, pid: 3315 null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Still creating... (10s elapsed) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Another app is currently holding the yum lock; waiting for it to exit... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): The other application is: yum null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Memory : 80 M RSS (314 MB VSZ) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Started: Sun Jul 21 18:56:19 2019 - 00:11 ago null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): State : Running, pid: 3315 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Another app is currently holding the yum lock; waiting for it to exit... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): The other application is: yum null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Memory : 80 M RSS (314 MB VSZ) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Started: Sun Jul 21 18:56:19 2019 - 00:13 ago null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): State : Running, pid: 3315 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Existing lock /var/run/yum.pid: another copy is running as pid 3445. null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Another app is currently holding the yum lock; waiting for it to exit... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): The other application is: yum null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Memory : 69 M RSS (285 MB VSZ) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Started: Sun Jul 21 18:56:32 2019 - 00:02 ago null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): State : Running, pid: 3445 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Resolving Dependencies null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): --> Running transaction check null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package amazon-linux-extras.noarch 0:1.6.7-1.amzn2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package amazon-linux-extras.noarch 0:1.6.8-1.amzn2 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package amazon-linux-extras-yum-plugin.noarch 0:1.6.7-1.amzn2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package amazon-linux-extras-yum-plugin.noarch 0:1.6.8-1.amzn2 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package ec2-hibinit-agent.noarch 0:1.0.0-3.amzn2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package ec2-hibinit-agent.noarch 0:1.0.0-4.amzn2 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package ec2-instance-connect.noarch 0:1.1-7.amzn2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package ec2-instance-connect.noarch 0:1.1-9.amzn2 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package kernel.x86_64 0:4.14.128-112.105.amzn2 will be installed null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package libcap-ng.x86_64 0:0.7.5-4.amzn2.0.2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package libcap-ng.x86_64 0:0.7.5-4.amzn2.0.4 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package nss-softokn.x86_64 0:3.36.0-5.amzn2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package nss-softokn.x86_64 0:3.36.0-5.amzn2.0.1 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package nss-softokn-freebl.x86_64 0:3.36.0-5.amzn2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package nss-softokn-freebl.x86_64 0:3.36.0-5.amzn2.0.1 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package openssh.x86_64 0:7.4p1-16.amzn2.0.5 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package openssh.x86_64 0:7.4p1-16.amzn2.0.6 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package openssh-clients.x86_64 0:7.4p1-16.amzn2.0.5 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package openssh-clients.x86_64 0:7.4p1-16.amzn2.0.6 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package openssh-server.x86_64 0:7.4p1-16.amzn2.0.5 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package openssh-server.x86_64 0:7.4p1-16.amzn2.0.6 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package python-urllib3.noarch 0:1.24.1-1.amzn2.0.1 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package python-urllib3.noarch 0:1.24.3-1.amzn2.0.1 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package systemtap-runtime.x86_64 0:3.2-4.amzn2.0.2 will be updated null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package systemtap-runtime.x86_64 0:4.1-0.20190208git4e76869512d2.amzn2.0.2 will be an update null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): --> Processing Dependency: libjson-c.so.2()(64bit) for package: systemtap-runtime-4.1-0.20190208git4e76869512d2.amzn2.0.2.x86_64 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): --> Running transaction check null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package json-c.x86_64 0:0.11-4.amzn2.0.3 will be installed null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): --> Finished Dependency Resolution null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Dependencies Resolved null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ======================================== null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Package Arch Version null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Repository Size null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ======================================== null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): kernel x86_64 4.14.128-112.105.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 20 M null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amazon-linux-extras null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): noarch 1.6.8-1.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 35 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amazon-linux-extras-yum-plugin null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): noarch 1.6.8-1.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 9.5 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ec2-hibinit-agent null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): noarch 1.0.0-4.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 13 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ec2-instance-connect null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): noarch 1.1-9.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 20 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): libcap-ng x86_64 0.7.5-4.amzn2.0.4 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 25 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): nss-softokn x86_64 3.36.0-5.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 318 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): nss-softokn-freebl null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): x86_64 3.36.0-5.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 225 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): openssh x86_64 7.4p1-16.amzn2.0.6 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 509 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): openssh-clients null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): x86_64 7.4p1-16.amzn2.0.6 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 657 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): openssh-server null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): x86_64 7.4p1-16.amzn2.0.6 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 461 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): python-urllib3 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): noarch 1.24.3-1.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 165 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): systemtap-runtime null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): x86_64 4.1-0.20190208git4e76869512d2.amzn2.0.2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 442 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing for dependencies: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): json-c x86_64 0.11-4.amzn2.0.3 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 31 k null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Transaction Summary null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ======================================== null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Install 1 Package (+1 Dependent package) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Upgrade 12 Packages null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Total download size: 23 M null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Downloading packages: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Delta RPMs disabled because /usr/bin/applydeltarpm not installed. null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (1/14): amazon-lin | 35 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (2/14): amazon-lin | 9.5 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (3/14): ec2-hibini | 13 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (4/14): ec2-instan | 20 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (5/14): json-c-0.1 | 31 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (6/14): libcap-ng- | 25 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (7/14): nss-softok | 318 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (8/14): nss-softok | 225 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (9/14): openssh-7. | 509 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (10/14): openssh-c | 657 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (11/14): openssh-s | 461 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (12/14): python-ur | 165 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (14/14): syste 56% | 13 MB --:-- ETA null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (13/14): systemtap | 442 kB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): (14/14): kernel-4. | 20 MB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---------------------------------------- null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Total 34 MB/s | 23 MB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running transaction check null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running transaction test null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Transaction test succeeded null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running transaction null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [ ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [# ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [## ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [### ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [#### ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [##### ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [###### ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [####### ] 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh-7.4p1-16 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [ ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [# ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [## ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [### ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [#### ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [##### ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [###### ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [####### ] 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh-server-7 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : json-c- [ ] 3/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : json-c- [##### ] 3/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : json-c- [###### ] 3/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : json-c- [####### ] 3/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : json-c-0.11-4.am 3/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [ ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [# ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [## ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [### ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [#### ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [##### ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [###### ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [####### ] 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-softokn-free 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [ ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [# ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [## ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [### ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [#### ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [##### ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [###### ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-sof [####### ] 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : nss-softokn-3.36 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [ ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [# ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [## ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [### ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [#### ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [##### ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [###### ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemt [####### ] 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : systemtap-runtim 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ec2-instance-connect:x:998:996::/home/ec2-instance-connect:/sbin/nologin null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-ins [ ] 7/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-ins [# ] 7/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-ins [### ] 7/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-ins [####### ] 7/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-instance-con 7/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [ ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [# ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [## ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [### ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [#### ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [##### ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [###### ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh [####### ] 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : openssh-clients- 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [ ] 9/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [### ] 9/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [####### ] 9/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon-linux-ext 9/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [ ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [# ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [## ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [### ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [#### ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [##### ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon- [####### ] 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : amazon-linux-ext 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [ ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [# ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Still creating... (20s elapsed) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [## ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [### ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [#### ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [##### ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [###### ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel- [####### ] 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : kernel-4.14.128- 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : libcap- [ ] 12/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : libcap- [### ] 12/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : libcap- [####### ] 12/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : libcap-ng-0.7.5- 12/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-hib [ ] 13/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-hib [###### ] 13/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-hib [####### ] 13/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : ec2-hibinit-agen 13/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [ ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [# ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [## ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [### ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [#### ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [##### ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [###### ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python- [####### ] 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updating : python-urllib3-1 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : ec2-instance-con 15/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): /var/tmp/rpm-tmp.OVFhDB: line 1: systemd_postun_with_restart: command not found null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : openssh-server-7 16/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : openssh-clients- 17/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : nss-softokn-3.36 18/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : amazon-linux-ext 19/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : amazon-linux-ext 20/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : ec2-hibinit-agen 21/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : python-urllib3-1 22/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : nss-softokn-free 23/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : openssh-7.4p1-16 24/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : systemtap-runtim 25/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Cleanup : libcap-ng-0.7.5- 26/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Still creating... (30s elapsed) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : openssh-server-7 1/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : nss-softokn-3.36 2/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : nss-softokn-free 3/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : python-urllib3-1 4/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : ec2-hibinit-agen 5/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : libcap-ng-0.7.5- 6/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : systemtap-runtim 7/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : kernel-4.14.128- 8/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : json-c-0.11-4.am 9/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : openssh-7.4p1-16 10/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : amazon-linux-ext 11/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : ec2-instance-con 12/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : openssh-clients- 13/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : amazon-linux-ext 14/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : ec2-instance-con 15/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : ec2-hibinit-agen 16/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : openssh-clients- 17/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : amazon-linux-ext 18/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : systemtap-runtim 19/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : nss-softokn-free 20/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : openssh-7.4p1-16 21/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : nss-softokn-3.36 22/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : libcap-ng-0.7.5- 23/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : openssh-server-7 24/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : amazon-linux-ext 25/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : python-urllib3-1 26/26 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installed: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): kernel.x86_64 0:4.14.128-112.105.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Dependency Installed: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): json-c.x86_64 0:0.11-4.amzn2.0.3 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Updated: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amazon-linux-extras.noarch 0:1.6.8-1.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amazon-linux-extras-yum-plugin.noarch 0:1.6.8-1.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ec2-hibinit-agent.noarch 0:1.0.0-4.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ec2-instance-connect.noarch 0:1.1-9.amzn2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): libcap-ng.x86_64 0:0.7.5-4.amzn2.0.4 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): nss-softokn.x86_64 0:3.36.0-5.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): nss-softokn-freebl.x86_64 0:3.36.0-5.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): openssh.x86_64 0:7.4p1-16.amzn2.0.6 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): openssh-clients.x86_64 0:7.4p1-16.amzn2.0.6 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): openssh-server.x86_64 0:7.4p1-16.amzn2.0.6 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): python-urllib3.noarch 0:1.24.3-1.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): systemtap-runtime.x86_64 0:4.1-0.20190208git4e76869512d2.amzn2.0.2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Complete! null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Loaded plugins: extras_suggestions, null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): : langpacks, priorities, null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): : update-motd null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Package python2-setuptools-38.4.0-3.amzn2.0.6.noarch already installed and latest version null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Resolving Dependencies null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): --> Running transaction check null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ---> Package python2-pip.noarch 0:9.0.3-1.amzn2.0.1 will be installed null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Still creating... (40s elapsed) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): --> Finished Dependency Resolution null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Dependencies Resolved null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ======================================== null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Package Arch Version null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Repository Size null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ======================================== null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): python2-pip noarch 9.0.3-1.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): amzn2-core 1.9 M null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Transaction Summary null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): ======================================== null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Install 1 Package null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Total download size: 1.9 M null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installed size: 8.3 M null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Downloading packages: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): python2-pip-9.0.3- | 1.9 MB 00:00 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running transaction check null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running transaction test null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Transaction test succeeded null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running transaction null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [ ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [# ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [## ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [### ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [#### ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [##### ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [###### ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [####### ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2- [######## ] 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing : python2-pip-9.0.3- 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Verifying : python2-pip-9.0.3- 1/1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installed: null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): python2-pip.noarch 0:9.0.3-1.amzn2.0.1 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Complete! null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): WARNING: Running pip install with root privileges is generally not a good idea. Try `pip install --user` instead. null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Collecting httplib2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Downloading https://files.pythonhosted.org/packages/5c/f3/7206894743389a4f727b73e6df4da60c9ee3cbef3f5afd82814592eafa8b/httplib2-0.13.0.tar.gz (219kB) null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 4% |█▌ | 10kB 35.1MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 9% |███ | 20kB 21.3MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 13% |████▌ | 30kB 17.6MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 18% |██████ | 40kB 20.0MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 23% |███████▌ | 51kB 19.3MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 27% |█████████ | 61kB 18.5MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 32% |██████████▌ | 71kB 20.0MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 37% |████████████ | 81kB 19.1MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 41% |█████████████▍ | 92kB 20.4MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 46% |███████████████ | 102kB 19.1MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 51% |████████████████▍ | 112kB 19.4MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 55% |██████████████████ | 122kB 21.2MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 60% |███████████████████▍ | 133kB 23.3MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 65% |█████████████████████ | 143kB 18.1MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 69% |██████████████████████▍ | 153kB 19.3MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 74% |███████████████████████▉ | 163kB 21.0MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 79% |█████████████████████████▍ | 174kB 21.3MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 83% |██████████████████████████▉ | 184kB 23.8MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 88% |████████████████████████████▍ | 194kB 24.0MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 93% |█████████████████████████████▉ | 204kB 28.1MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 97% |███████████████████████████████▍| 215kB 24.0MB/s eta 0:00:01 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): 100% |████████████████████████████████| 225kB 2.3MB/s null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Installing collected packages: httplib2 null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Running setup.py install for httplib2 ... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): - null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec):done null_resource.ProvisionRemoteHostsIpToAnsibleHosts (remote-exec): Successfully installed httplib2-0.13.0 null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Provisioning with 'local-exec'... null_resource.ProvisionRemoteHostsIpToAnsibleHosts (local-exec): Executing: ["/bin/sh" "-c" "echo 3.86.198.164 >> hosts"] null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Creation complete after 44s (ID: 8455640802195852092) null_resource.ModifyApplyAnsiblePlayBook: Creating... null_resource.ModifyApplyAnsiblePlayBook: Provisioning with 'local-exec'... null_resource.ModifyApplyAnsiblePlayBook (local-exec): Executing: ["/bin/sh" "-c" "sed -i -e '/hosts:/ s/: .*/: terra_ansible_host/' play.yml"] null_resource.ModifyApplyAnsiblePlayBook: Provisioning with 'local-exec'... null_resource.ModifyApplyAnsiblePlayBook (local-exec): Executing: ["/bin/sh" "-c" "sleep 10; ansible-playbook -i hosts play.yml"] null_resource.ModifyApplyAnsiblePlayBook: Still creating... (10s elapsed) null_resource.ModifyApplyAnsiblePlayBook (local-exec): PLAY [install app] ************************************************************* null_resource.ModifyApplyAnsiblePlayBook (local-exec): TASK [Install git.] ************************************************************ null_resource.ModifyApplyAnsiblePlayBook: Still creating... (20s elapsed) null_resource.ModifyApplyAnsiblePlayBook: Still creating... (30s elapsed) null_resource.ModifyApplyAnsiblePlayBook (local-exec): changed: [3.86.198.164] => (item=git) null_resource.ModifyApplyAnsiblePlayBook: Still creating... (40s elapsed) null_resource.ModifyApplyAnsiblePlayBook (local-exec): changed: [3.86.198.164] => (item=htop) null_resource.ModifyApplyAnsiblePlayBook (local-exec): TASK [Install a list of packages] ********************************************** null_resource.ModifyApplyAnsiblePlayBook: Still creating... (50s elapsed) null_resource.ModifyApplyAnsiblePlayBook: Still creating... (1m1s elapsed) null_resource.ModifyApplyAnsiblePlayBook (local-exec): changed: [3.86.198.164] null_resource.ModifyApplyAnsiblePlayBook (local-exec): TASK [start httpd] ************************************************************* null_resource.ModifyApplyAnsiblePlayBook: Still creating... (1m11s elapsed) null_resource.ModifyApplyAnsiblePlayBook (local-exec): changed: [3.86.198.164] null_resource.ModifyApplyAnsiblePlayBook (local-exec): PLAY RECAP ********************************************************************* null_resource.ModifyApplyAnsiblePlayBook (local-exec): 3.86.198.164 : ok=3 changed=3 unreachable=0 failed=0 null_resource.ModifyApplyAnsiblePlayBook: Creation complete after 1m18s (ID: 5014735370722366347) Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
AWS instance:
Apache default page:
htop:
$ terraform destroy null_resource.ConfigureAnsibleLabelVariable: Refreshing state... (ID: 5076260706150615561) aws_instance.myInstanceAWS: Refreshing state... (ID: i-0de203fa9e9766ae1) null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Refreshing state... (ID: 8455640802195852092) null_resource.ModifyApplyAnsiblePlayBook: Refreshing state... (ID: 5014735370722366347) An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: - destroy Terraform will perform the following actions: - aws_instance.myInstanceAWS - null_resource.ConfigureAnsibleLabelVariable - null_resource.ModifyApplyAnsiblePlayBook - null_resource.ProvisionRemoteHostsIpToAnsibleHosts Plan: 0 to add, 0 to change, 4 to destroy. Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm. Enter a value: yes null_resource.ModifyApplyAnsiblePlayBook: Destroying... (ID: 5014735370722366347) null_resource.ConfigureAnsibleLabelVariable: Destroying... (ID: 5076260706150615561) null_resource.ConfigureAnsibleLabelVariable: Destruction complete after 0s null_resource.ModifyApplyAnsiblePlayBook: Destruction complete after 0s null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Destroying... (ID: 8455640802195852092) null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Destruction complete after 0s aws_instance.myInstanceAWS: Destroying... (ID: i-0de203fa9e9766ae1) aws_instance.myInstanceAWS: Still destroying... (ID: i-0de203fa9e9766ae1, 10s elapsed) aws_instance.myInstanceAWS: Still destroying... (ID: i-0de203fa9e9766ae1, 20s elapsed) aws_instance.myInstanceAWS: Still destroying... (ID: i-0de203fa9e9766ae1, 30s elapsed) aws_instance.myInstanceAWS: Destruction complete after 34s Destroy complete! Resources: 4 destroyed.
In a transition to arrange our folders (via roles and tasks), we can get the code with two folders (ansible and terraform) from roles branch in https://github.com/Einsteinish/Using-Ansible-with-Terraform.git.
$ git branch master * roles
The output from the terraform run remains the same as before.
In addition to roles and tasks, the roles_with_vault_and_S3 has more features such as S3 file download and passing variables from Terraform to Ansible etc.
$ git branch master roles * roles_with_vault_and_S3
The output from the terraform run remains the same as before. Note also that this is quite a contrived sample and actually, we're not installing the vault but just installs the tls certs from S3 into our instance.
To get the AWS secret and key, we use lookup() in ansible/roles/vault/tasks/vault-tls-cert-install-configure.yml file:
- name: Download vault tls crt key file from s3 aws_s3: bucket: "my-tls-cert" object: "{{ consul_datacenter }}/vault.key.pem" dest: /opt/vault/tls/vault.key.pem mode: get aws_access_key: "{{ lookup('env', 'CONSUL_AWS_ACCESS_KEY') }}" aws_secret_key: "{{ lookup('env', 'CONSUL_AWS_SECRET_KEY') }}"
One of the variables (consul_datacenter which is defined in variables.tf) is passed as the following ( terraform/ansible_vars.yml.tpl):
consul_datacenter: ${consul_datacenter}
The variable is a sort of environment variable such as "dev/staging/prod"!
To render a template, we need the following as well (terraform/main.tf):
# render temp file containing our ansible variables resource "local_file" "ansible_vars" { content = "${data.template_file.ansible_vars.rendered}" filename = "${path.root}/ansible_vars.yml" } resource "null_resource" "ModifyApplyAnsiblePlayBook" { provisioner "local-exec" { command = "sed -i -e '/hosts:/ s/: .*/: ${var.dev_host_label}/' ../ansible/play.yml" #change host label in playbook dynamically } provisioner "local-exec" { command = <<EOT sleep 10; ansible-playbook -i hosts ../ansible/play.yml \ --extra-vars @"${local_file.ansible_vars.filename}" EOT } depends_on = ["null_resource.ProvisionRemoteHostsIpToAnsibleHosts"] }
Here is the files we have after the terraform run:
One of the useful tip to run Ansible is the terraform taint command. By using the command, we can just run the Ansible portion not touching (create or destroy) the AWS instance. For example, we can run terraform apply after just tainting a Null resource:
$ terraform taint null_resource.ModifyApplyAnsiblePlayBook The resource null_resource.ModifyApplyAnsiblePlayBook in the module root has been marked as tainted! $ terraform apply null_resource.ConfigureAnsibleLabelVariable: Refreshing state... (ID: 728761341796776058) aws_instance.myInstanceAWS: Refreshing state... (ID: i-0c6ad8ade2a5c06c0) null_resource.ProvisionRemoteHostsIpToAnsibleHosts: Refreshing state... (ID: 5587046142189860255) null_resource.ModifyApplyAnsiblePlayBook: Refreshing state... (ID: 4775992726421100062) An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: -/+ destroy and then create replacement Terraform will perform the following actions: -/+ null_resource.ModifyApplyAnsiblePlayBook (tainted) (new resource required) id: "4775992726421100062" =>(forces new resource) Plan: 1 to add, 0 to change, 1 to destroy. ...
Ansible 2.0
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization