# How to use cloud-init to customize a windows virtual machine in oracle cloud on first boot using ansible

**URL:** <https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 26, 2019, 9:28am UTC](https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726 "2019-11-26T09:28:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Rawat](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Rahul\_Rawat](https://forum.ansible.com/u/Rahul_Rawat)\
**Post date:** [November 26, 2019, 9:28am UTC](https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726/1 "2019-11-26T09:28:08Z")

</div>

Hi,

I have created VM using oci-ansible-modules on oracle cloud. Now, I want to run powershell script on first boot with the use of cloud-init using ansible.

Means when my playbook run from ansible role,  
Firstly, VM create using oci-anisble-module and  
secondly, powershell run with the help of cloud-init using ansible role.

regards,  
Rahul Rawat

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [November 26, 2019, 9:42am UTC](https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726/2 "2019-11-26T09:42:12Z")

</div>

Is this the same question you asked a week or so ago? If so, I think we need more detail.

cloud-init happens on launch. Under some circumstances, it can happen on boot as well.

[https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-user-data.html)

Not sure what you mean by running powershell “with the help of cloud-init using ansible role”…

Regards, K.

---

<div class="post-metadata">

**Author:** ![Rahul\_Rawat](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Rahul\_Rawat](https://forum.ansible.com/u/Rahul_Rawat)\
**Post date:** [November 26, 2019, 10:01am UTC](https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726/3 "2019-11-26T10:01:15Z")

</div>

Yes, it’s the same question.  
We just want when windows instance created using oci-ansible-modules from ansible role. On first boot, I have powershell script which should be run automatically.  
Powershell script should be invoke or run through cloud-init/user\_data.

I have an idea about ansibe role and oci-ansible-modules. But new in cloud-init and user\_data script.

Here is my main task ansible playbook which create VM in oracle cloud.

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [November 26, 2019, 10:20am UTC](https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726/4 "2019-11-26T10:20:03Z")

</div>

So - what is your actual question?

I suggest you start with an extremely simple userdata script that does something simple like create a file.

If you select at the launched instance in the AWS Console instance list, you can view the userdata using Actions → Instance Settings → View/Change User Data. This is a good way to check that your Ansible play did create an instance with userdata supplied, and to check that the userdata it supplied is what you expected.

If the above shows that Ansible is providing userdata to the instance, the next step is to check whether your userdata was executed at launch time. You can retrieve the system log of your launched instance by selecting the instance in the AWS Console instance list and then Actions → Instance Settings → Get System Log. If your userdata script did not run correctly, you should see error messages in this log.

Let us know how you go.

Regards, K.

---

<div class="post-metadata">

**Author:** ![BrokeDBA](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@BrokeDBA](https://forum.ansible.com/u/BrokeDBA)\
**Post date:** [May 27, 2020, 4:47pm UTC](https://forum.ansible.com/t/how-to-use-cloud-init-to-customize-a-windows-virtual-machine-in-oracle-cloud-on-first-boot-using-ansible/31726/5 "2020-05-27T16:47:46Z")

</div>

Hi Rahul,  
Did you finally get it to run ?  
I am trying to do the same for an oracle cloud vm launch.
