Ok, Got through that hurdle now next!
Please find below update file
- name: Create Azure VM
hosts: localhost
connection: local
tasks:
- name: Create resource group
azure_rm_resourcegroup:
name: rg_networking
location: australiasoutheast
- name: Create virtual network
azure_rm_virtualnetwork:
resource_group: rg_networking
name: vmnet_groups_preprod
address_prefixes: "10.97.0.0/16"
- name: Add subnet
azure_rm_subnet:
resource_group: rg_networking
name: subnet_ax
address_prefix: "10.97.3.0/24"
virtual_network: vmnet_groups_preprod
- name: Create public IP address
azure_rm_publicipaddress:
resource_group: rg_networking
allocation_method: Static
name: NXTPREPWEB-1_IP
register: output_ip_address
- name: Dump public IP for VM which will be created
debug:
msg: "The public IP is {{ output_ip_address.state.ip_address }}."
- name: Create Network Security Group that allows RDP
azure_rm_securitygroup:
resource_group: rg_networking
name: nsg_subnet_ax
rules:
- name: RDP
protocol: Tcp
destination_port_range: 3389
access: Allow
priority: 1002
direction: Inbound
- name: Create virtual network inteface card
azure_rm_networkinterface:
resource_group: rg_networking
name: subnet_ax_iis_nic-1
virtual_network: vmnet_groups_preprod
subnet: subnet_ax
public_ip_name: NXTPREPWEB-1_IP
security_group: nsg_subnet_ax
- name: Create VM
azure_rm_virtualmachine:
resource_group: rg_networking
name: NXTPREPWEB-1
vm_size: Standard_DS1_v2
admin_username: axlocaladmin
admin_password: Hash#Dollar$135
os_type: Windows
network_interfaces: subnet_ax_iis_nic-1
image:
offer: WindowsServer
publisher: MicrosoftWindowsServer
sku: '2016-Datacenter'
version: latest
- name: install features on new Azure Windows Server
hosts: windows
gather_facts: no
tasks:
- name: wait for connection to be online
wait_for_connection:
- name: Install IIS (Web-Server and Web-Common-Http)
win_feature:
name:
- Web-Server
- Web-Common-Http
state: present
- name: Install IIS Web-Server with sub features and management tools
win_feature:
name: Web-Server
state: present
include_sub_features: True
include_management_tools: True
register: feature_install
- name: reboot if installing Web-Server feature requires it
win_reboot:
when: win_feature.reboot_required
Now, when I run through Azure cloud shell, it gives me error as below:
When I login to Azure cloud shell to execute it keeps in complaining that
[WARNING]: Could not match supplied host pattern, ignoring: windows
PLAY [install features on new Azure Windows Server]
************************************************************************************************************************
skipping: no hosts matched
PLAY RECAP
*****************************************************************************************************************************************************************
localhost : ok=9 changed=0 unreachable=0 failed=0
Unfortunately there is no directory like /etc/ansible/host so how to inject
configuration on newly created Azure VM?
Kind Regards,
Ameya Agashe
On Friday, 12 October 2018 13:15:50 UTC+11, ameya agashe wrote:
>
> Hi All,
>
> I need your assistance to resolve this issue.
>
> Error details when I run in -vvv option:
>
> Using module file
> /opt/ansible/local/lib/python2.7/site-packages/ansible/modules/windows/win_feature.py
> <127.0.0.1> PUT
> /home/ameya/.ansible/tmp/ansible-local-1269sNJo2N/tmpn6Pzqa TO
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/win_feature.py
> <127.0.0.1> PUT
> /home/ameya/.ansible/tmp/ansible-local-1269sNJo2N/tmpE9GgM5 TO
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/args
> <127.0.0.1> EXEC /bin/sh -c 'chmod u+x
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/win_feature.py
>
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/args &&
> sleep 0'
> <127.0.0.1> EXEC /bin/sh -c '/opt/ansible/bin/python2
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/win_feature.py
>
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/args &&
> sleep 0'
> <127.0.0.1> EXEC /bin/sh -c 'rm -f -r
> /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/ >
> /dev/null 2>&1 && sleep 0'
> fatal: [localhost]: FAILED! => {
> "changed": false,
> "module_stderr": "",
> "module_stdout": "",
> "msg": "MODULE FAILURE",
> "rc": 0
> }
>
> My Ansible yaml file is below, note it's not an idea yaml but I want to
> get a base build working
>
> - name: Create Azure VM
> hosts: localhost
> connection: local
> tasks:
> - name: Create resource group
> azure_rm_resourcegroup:
> name: rg_networking
> location: australiasoutheast
> - name: Create virtual network
> azure_rm_virtualnetwork:
> resource_group: rg_networking
> name: vmnet_groups_preprod
> address_prefixes: "10.97.0.0/16"
> - name: Add subnet
> azure_rm_subnet:
> resource_group: rg_networking
> name: subnet_ax
> address_prefix: "10.97.3.0/24"
> virtual_network: vmnet_groups_preprod
> - name: Create public IP address
> azure_rm_publicipaddress:
> resource_group: rg_networking
> allocation_method: Static
> name: NXTPREPWEB-1_IP
> register: output_ip_address
> - name: Dump public IP for VM which will be created
> debug:
> msg: "The public IP is {{ output_ip_address.state.ip_address }}."
> - name: Create Network Security Group that allows RDP
> azure_rm_securitygroup:
> resource_group: rg_networking
> name: nsg_subnet_ax
> rules:
> - name: RDP
> protocol: Tcp
> destination_port_range: 3389
> access: Allow
> priority: 1002
> direction: Inbound
> - name: Create virtual network inteface card
> azure_rm_networkinterface:
> resource_group: rg_networking
> name: subnet_ax_iis_nic-1
> virtual_network: vmnet_groups_preprod
> subnet: subnet_ax
> public_ip_name: NXTPREPWEB-1_IP
> security_group: nsg_subnet_ax
> - name: Create VM
> azure_rm_virtualmachine:
> resource_group: rg_networking
> name: NXTPREPWEB-1
> vm_size: Standard_DS1_v2
> admin_username: axlocaladmin
> admin_password: Hash#Dollar$135
> os_type: Windows
> network_interfaces: subnet_ax_iis_nic-1
> image:
> offer: WindowsServer
> publisher: MicrosoftWindowsServer
> sku: '2016-Datacenter'
> version: latest
> - name: Install IIS (Web-Server and Web-Common-Http)
> win_feature:
> name:
> - Web-Server
> - Web-Common-Http
> state: present
>
> - name: Install IIS Web-Server with sub features and management tools
> win_feature:
> name: Web-Server
> state: present
> include_sub_features: True
> include_management_tools: True
> register: win_feature
>
> - name: reboot if installing Web-Server feature requires it
> win_reboot:
> when: win_feature.reboot_required
>
> Would appreciate any assistance offered.
>
> Kind Regards,
> Ameya Agashe
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c733d8f7-738e-4ec2-b975-d20ea0ed5d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.