https://pulumi.com logo
#getting-started
Title
# getting-started
l

lemon-ambulance-1111

11/09/2023, 6:34 AM
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

fierce-night-38522

11/09/2023, 3:11 PM
Hi @lemon-ambulance-1111! Is this being deployed into an EC2 instance? What type of instance are you referring to?
l

lemon-ambulance-1111

11/09/2023, 3:11 PM
Yes
Ec2
Whatever I am trying to run with ansible it's not working
f

fierce-night-38522

11/09/2023, 3:12 PM
Are there any stack traces or error logs available?
l

lemon-ambulance-1111

11/09/2023, 3:12 PM
No
f

fierce-night-38522

11/09/2023, 3:13 PM
Okay let me try to take a look into why this might be happening.
l

lemon-ambulance-1111

11/09/2023, 3:13 PM
Ok thanks
s

salmon-account-74572

11/09/2023, 4:04 PM
@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

lemon-ambulance-1111

11/13/2023, 6:51 AM
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

salmon-account-74572

11/13/2023, 2:50 PM
That looks like an SSH error. Are you able to manually open an SSH connection to the instance provisioned by Pulumi?
l

lemon-ambulance-1111

11/13/2023, 3:33 PM
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

salmon-account-74572

11/13/2023, 5:48 PM
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

lemon-ambulance-1111

11/17/2023, 1:31 AM
@salmon-account-74572 Thanks , now I can bring up pulumi with ansible
s

salmon-account-74572

11/17/2023, 2:28 PM
Excellent, glad to hear it’s working!
l

lemon-ambulance-1111

11/17/2023, 2:29 PM
But it's getting stuck at some point and not running the playbook
s

salmon-account-74572

11/17/2023, 2:30 PM
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/