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.
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.
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.