Hi Jon, Thank you very much for the reply.
Sincerely, Akim On Tuesday, November 7, 2017 at 4:10:50 AM UTC-5, J Hawkesworth wrote: > > > I don't use ec2 but I think having the 'connection: local' for your > windows hosts is causing you problems, as it appears to be attempting to > use the win_feature.py (documentation) instead of the win_feature.ps1 > (actual windows module code). > The connection type for windows hosts, at the moment anyway, has to be > winrm, otherwise ansible will default to assuming it can use python modules. > > I think you are almost there, but will need to make sure when you hit the > > hosts: windows > > (new play in your playbook) you have got the all the windows connection > settings set up in your group_vars. I don't know what you would need to do > to discover the correct username and password to connect (probably as > Administrator user) to your new ec2 host, but those settings will need to > be set up by that point. See this bit of the documentation for the > windows-specific variables that you need to set up in your inventory / > group_vars: > http://docs.ansible.com/ansible/latest/intro_windows.html#inventory > > Once you have that figured out, I'd recommend using 'wait_for_connection' > module to make sure that you can actually connect to your new instance, > probably with a bit of a wait period to give the machine time to boot up > and complete start up activities. wait_for_connection is pretty smart and > assuming your inventory/group_vars are configured ok will test that you can > make a winrm connection for windows hosts (and ssh or whatever other > transport for non-windows hosts). > > Bear in mind too that Web-Server is a pretty big feature and I have seen > it take nearly 5 minutes to install (on s2012r2) so given your t2.micro > instance is 1 cpu it may take a while to complete. > > Hope this helps, > > Jon > > > > > > On Monday, November 6, 2017 at 11:31:09 PM UTC, Akim Grudzitsky wrote: >> >> I updated the playbook. I added a second play to target the new Windows >> host and some further steps after the ec2 module to add the new host to >> the inventory. >> >> However, I'm still getting the same error. The task is failing. >> >> *Updated Playbook:* >> >> --- # EC2 MODULE - PROVISIONING EXAMPLE >> >> - hosts: localhost >> >> connection: local >> >> remote_user: test >> >> become: yes >> >> gather_facts: no >> >> vars_files: >> >> - files/awscreds.yml >> >> tasks: >> >> - name: Provision of a set of Windows instances >> >> ec2: >> >> aws_access_key: "{{ aws_id }}" >> >> aws_secret_key: "{{ aws_key }}" >> >> region: "{{ aws_region }}" >> >> image: ami-e3bb7399 >> >> instance_type: t2.micro >> >> count: 1 >> >> vpc_subnet_id: subnet-112b2c3d >> >> assign_public_ip: yes >> >> count_tag: >> >> Name: CountTagDemo >> >> instance_tags: >> >> Name: WinDemo >> >> register: ec2 >> >> >> - name: Print the results >> >> debug: var=item >> >> with_items: ec2.instances >> >> >> - name: Add all instance public IPs to host group >> >> add_host: hostname={{ item.public_ip }} groups=windows >> >> with_items: "{{ ec2.instances }}" >> >> >> - name: Wait for the instances to boot >> >> wait_for: state=started >> >> with_items: ec2.instances >> >> >> - hosts: windows >> >> connection: local >> >> remote_user: test >> >> become: yes >> >> gather_facts: no >> >> vars_files: >> >> - files/awscreds.yml >> >> >> tasks: >> >> - name: Install IIS >> >> win_feature: >> >> name: "Web-Server" >> >> state: present >> >> restart: true >> >> include_sub_features: yes >> >> include_management_tools: yes >> >> >> *Error Message:* >> >> TASK [Install IIS] >> *********************************************************************** >> >> *task path: /home/test/Playbooks/awsec2win_provision.yml:47* >> >> Using module file >> /usr/lib/python2.7/site-packages/ansible-2.5.0-py2.7.egg/ansible/modules/windows/win_feature.py >> >> <> ESTABLISH LOCAL CONNECTION FOR USER: test >> >> <> EXEC /bin/sh -c 'echo ~ && sleep 0' >> >> <> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149 `" && >> echo ansible-tmp-1510010700.13-143481769279149="` echo >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149 `" ) && >> sleep 0' >> >> <> PUT /tmp/tmpfvOE2z TO >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/win_feature.py >> >> <> PUT /tmp/tmpzqtpyD TO >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/args >> >> <> EXEC /bin/sh -c 'chmod u+x >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/ >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/win_feature.py >> >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/args && >> sleep 0' >> >> <> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo >> BECOME-SUCCESS-fsnrdknpojaqmlsccnjclmrmrbdzokmc; /usr/bin/python >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/win_feature.py >> >> /home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/args; rm >> -rf "/home/test/.ansible/tmp/ansible-tmp-1510010700.13-143481769279149/" > >> /dev/null 2>&1'"'"' && sleep 0' >> >> fatal: []: FAILED! => { >> >> "changed": false, >> >> "failed": true, >> >> "module_stderr": "", >> >> "module_stdout": "", >> >> "msg": "MODULE FAILURE", >> >> "rc": 0 >> >> } >> >> to retry, use: --limit @/home/test/Playbooks/awsec2win_provision.retry >> >> >> PLAY RECAP ************************************************************* >> >> : ok=0 changed=0 unreachable=0 >> failed=1 >> >> localhost : ok=4 changed=2 unreachable=0 >> failed=0 >> >> >> Could you please advise if the playbook is correct or how it should be >> modified to install IIS server? >> Thank you. >> >> >> >> -- 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/deb9f93e-47e7-4b14-a9e5-4d3b6f5111bb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
