Is it possible to start ec2 Windows machine and run windows command using ansible playbook?

0 votes
Is it possible to start ec2 windows instance and run windows command after started the same ec2 instance using the same ansible-playbook from local system? Because VM taking some time to start... So how is possible with two tasks in the same playbook?
Aug 14 in Ansible by Lakshminarayanan
• 1,000 points

edited Aug 14 by MD 152 views

1 answer to this question.

0 votes

Hi@Lakshminarayanan,

Yes, you can do that. But after you launched your ec2 instance, you have to update your Ansible inventory file in the below format.

$ ec2-instance ansible_host=<<ec2-instance-ip>> ansible_user=ec2-user ansible_ssh_private_key_file=/location/of/the/keypair/your-key.pem

After that, you can run any command inside your EC2 instance.

name: Run any command
hosts: ec2-instance
become: yes
become_user: root
tasks: {{ write your commands }}
answered Aug 14 by MD
• 56,480 points
Everything seems ok in your playbook. Which protocol you are using to login to your remote windows system?
you mean should i do some thing like configuration in windows machine? Because its RDP. Its confusing bro. I can start and stop the remote windows instance whereas i cant do with windows commands. I didn't any special configuration before connect remote windows instance. Where im wrong.

Yes, I think so. Because if it is a Linux system then it can be done through SSH protocol. But it is a Windows system and it does not work on SSH by default. So as you are using RDB protocol, some configurations require. You can start and stop your instance because you don't have to login inside your instance to do that. But to run any command in your instance, you need to login to your instance.

uderstood bro. Can you tell me the steps to achieve this. Because im not aware about this.

Hi@Lakshminarayanan,

You can check the below blog. It has the steps to configure the Windows system as a managed node.

https://www.linuxtechi.com/manage-windows-host-using-ansible/

Related Questions In Ansible

0 votes
1 answer

Is it possible to run an Ansible Playbook in python script?

Hey @Cerci, Of course its possible. You ...READ MORE

answered Jan 17, 2019 in Ansible by Nicolas
8,077 views
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,240 points
6,138 views
0 votes
1 answer

Is it possible to run commands on ansible host?

If you just trying to run a ...READ MORE

answered Jan 9, 2019 in Ansible by Vijay
491 views
0 votes
1 answer

Is it possible to run a playbook with a crontab?

Ofcourse you can run ansible playbook with ...READ MORE

answered Jan 17, 2019 in Ansible by Yesha
1,981 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
677 views
+2 votes
1 answer
0 votes
1 answer

How to launch an EC2 instance using Ansible Playbook?

Hi@akhtar, Ansible has one module named ec2. This ...READ MORE

answered Aug 12 in Ansible by MD
• 56,480 points
83 views