By BostonTom
In this tutorial https://www.digitalocean.com/community/tutorials/how-to-use-ansible-with-terraform-for-configuration-management
There is mention in ~/terraform-ansible/apache-install.yml
to use the public key as:
key: “{{ lookup(‘file’, pub_key) }}”
command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i '${self.ipv4_address},' --private-key ${var.pvt_key} -e 'pub_key=${var.pub_key}' apache-install.yml"
However, I am getting this error, and I am unclear if the key path should be for my local or target directory? Am I declaring the path correctly? Could the example be improved?
Error: │ Error running command ‘ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u root -i ‘137.184.135.14,’ --private-key ~/.ssh/id_ed25519 -e ‘pub_key=~/.ssh/id_ed25519.pub’ apache-install.yml’: exit status 2. Output: │ PLAY [apache-install] ********************************************************** │ │ TASK [Gathering Facts] ********************************************************* │ fatal: [137.184.135.14]: FAILED! => {“changed”: false, “module_stderr”: “Shared connection to 137.184.135.14 closed.\r\n”, “module_stdout”: “/bin/sh: 1: /usr/bin/python: not found\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 127} │ to retry, use: --limit @/mnt/ap/ap/terraform-ansible/apache-install.retry
Note that I see this from Stack Overflow, not sure if it is relevant? https://stackoverflow.com/questions/29392369/ansible-ssh-private-key-in-source-control
I also am getting confused about keeping secrets vs storing things in the wrong places.
Could use an example .gitignore too
Also - for this digitalocean ssh key
data “digitalocean_ssh_key” “terraform” { name = “terraform” }
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
As this tutorial uses Terraform, what I could suggest is to follow the prerequisites on how to prepare all this up and mainly this tutorial here:
https://www.digitalocean.com/community/tutorials/how-to-use-terraform-with-digitalocean
It covers the SSH setup and configuration.
Hope that this helps. Best, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.