-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] ansible_playbook can't handle extra_vars changing #98
Comments
Noting that it has happened on v1.2.0 too:
|
@irishgordo Can you provide a minimal terraform config to reproduce this? I am able to change extra_vars on subsequent applies without error. |
@gravesm so sorry for the late reply! On the extra_vars portion, they're shifting but that's due to also the playbook shifting.
( I've slightly modified the message ) I think the gist is (on v1.3.0), that given something where we're leveraging a ternary based locals {
playbook-to-use = var.PRE_AIRGAP == true ? "ansible/pre-airgap.yaml" : "ansible/airgap.yaml"
}
resource "ansible_playbook" "vm-ansible-playbook" {
playbook = local.playbook-to-use
# Inventory configuration
name = "${var.VM_NAME} ansible_password=${var.VM_PASSWORD} ansible_host=${var.IP_ADDRESS} ansible_sudo_pass=${var.VM_PASSWORD} ansible_ssh_user=ubuntu ansible_ssh_common_args='-o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null' ansible_ssh_extra_args='-o StrictHostKeyChecking=no'"
check_mode = false
diff_mode = false
ignore_playbook_failure = false
replayable = true
verbosity = 6
}
And then calling the Terraform to build out the resource like:
Then after the Anisble playbook for in this use case "pre-airgap" is applied, so all network dependant items/configuration is set up with Terraform Ansible. After all that is set-up, the VM IP Address will have changed -> but it could still be interpolated with like
Which then is changing the underlying "playbook" property in the When we run that, what I notice, is that the first "iteration" fails. And it throws the "inconsistent plan" output. But then re-running it again:
It does succeed... it just like "fails" on the first time we change the underlying resource's So currently, I'm working to implement a solution where we'll just go ahead and have like a count, catching the failure the first time, then retrying, and if it fails a second time, that's an issue, but it "should" ™️ 😆 -- succeed. Maybe this is an anti-pattern in Terraform, with the Ansible resource, but I just couldn't think of another way to really accomplish what it is that we were trying to do with the overall series of ~10 integrations that needed to be pre-airgapped, then airgapped. Again this is a phenomenal tool and thank you a ton for your help on the project! |
Hi all, this project is awesome! Thank you so much for the v1.2.0 release recently!
I have been running into a bit of an issue on the v1.1.0 release and haven't updated it, but believe it still may persist.
Description
When provisioning an ansible_playbook TF resource, with some replayability and the underlying extra_vars change, the ansible_playbook fails to re-run.
Reproduce
Have some extra_vars defined.
Provision, w/ replayability set to true.
Change those extra_vars.
Re-provision, w/ replayability set to true.
Workaround
I've found that, "re-running" it after it fails, fixes it.
But it always seems to fail first.
The text was updated successfully, but these errors were encountered: