Hi Team, I am trying to deploy ansible with pulumi...
# getting-started
l
Hi Team, I am trying to deploy ansible with pulumi. While running the pulumi up infrastructure is creating and ansible playbook is deploying and it shows success. When I login into the instance it's blank. With ansible i am trying to install some packages,..... Reference: https://github.com/pulumi/pulumi-command/tree/master/examples/simple-ansible
f
Hi @lemon-ambulance-1111! Is this being deployed into an EC2 instance? What type of instance are you referring to?
l
Yes
Ec2
Whatever I am trying to run with ansible it's not working
f
Are there any stack traces or error logs available?
l
No
f
Okay let me try to take a look into why this might be happening.
l
Ok thanks
s
@lemon-ambulance-1111 Can you share the playbook you're trying to run? My initial thought is that you're going to need to generate and use an Ansible inventory file so that Ansible has the necessary information to connect to the EC2 instance you're provisioning via Pulumi.
Oh, and can you share the specific Pulumi code you're using?
l
Due to some security reasons I am not able to share the code but I will send you, how I invoke ansible inside pulumi
Diagnostics: commandLocalCommand (playAnsiblePlaybook(nd): error: exit status 4: running "ANSIBLE HOST_KEY_CHECKING=False isc ansible-playbook -u hostname -i 'XXXXXXX', playbook.yaml": Identities available via memento-agent: Touch ID [] Touch required for touchid-mac in 308 Seconds. PLAY [Running Script Part ply] TASK [croete directories] failed: [XXXXX] (item/efs/dc_repo software)-> {"ansible_loop_var": "item", "item": "/efs/dc_repo_software", "msg": "Failed to connect to the host via ssh: hostname@XXXX: Permission denied (publickey).", "unreachable": true}
s
That looks like an SSH error. Are you able to manually open an SSH connection to the instance provisioned by Pulumi?
l
Since I am using iscloud, which is a different provider, I don't have a private key like aws
This is how I invoke ansible inside pulumi play_ansible = command.local.Command("playansible", create=vm.hostname.apply(lambda hostname: f"""\ ANSIBLE_HOST_KEY_CHECKING=False ISC ansible-playbook \ -u hostname \ -i '{hostname}', \ playbook.yaml"""))
s
OK, but Ansible uses SSH, and so you’ll need to ensure you can open an SSH connection in some fashion that Ansible supports. Whether that’s using private key authentication or username and password doesn’t matter.
l
@salmon-account-74572 Thanks , now I can bring up pulumi with ansible
s
Excellent, glad to hear it’s working!
l
But it's getting stuck at some point and not running the playbook
s
Have a look at this blog post, there are some specific flags you need to use when running
ansible-playbook
so that it works as expected: https://www.pulumi.com/blog/deploy-wordpress-aws-pulumi-ansible/