Re: [ansible-project] wait_for module

2017-11-07 Thread Kai Stian Olstad

On 08.11.2017 07:20, coach rhca wrote:
Thanks Kai for that insight , i have taken out the port=22 and include 
the
timeout=600 option in wait_for module  in  order to check the services 
by

login to server. Also can we set different timeout values for different
host in wait_for module.


You can have a variable for each host that you specify the timeout.


Can you please throw some light as i am created a
playbook for reboot and calling it in other playbook by specifying 
specific

host. like below but its not working .


There is a lot of errors in your playbook, you should read up on YAML 
file syntax.

http://docs.ansible.com/ansible/latest/YAMLSyntax.html

And then study the other examples you find all over the documentation 
and remember to pay attention to the indentation since that is very 
important in YAML.




---
 tasks:
   shell: sleep 2 && shutdown -r now
   async: 1
   poll: 0
   ignore_errors: true


This is a task file, it can't have "tasks:" in it.
Remove the tasks and add a dash in front of the shell line and make sure 
the indentation is correct.




server.yml

---
- name: for the individual hosts
- hosts: 192.168.3.154 <( This server requires to wait for the 
server to come online after reboot )


Since you are using the name, you can't have the dash on hosts:



  tasks:
   include: tasks/restart1.yml


The include is missing a dash, and need to be indented properly.



   - name: wait for the server to be online
 local_action: wait_for host={{ inventory_hostname }} state=started 
delay=5 timeout=120


- hosts: 192.168.3.153 < ( this server doesnot require to 
wait for the server to come back after reboot )

  tasks:
   - include: tasks/restart1.yml


Here the indentation is incorrect.

--
Kai Stian Olstad

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5baaa1c3a2a9b6ca225f09612873e24b%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] wait_for module

2017-11-07 Thread coach rhca
Thanks Kai for that insight , i have taken out the port=22 and include the
timeout=600 option in wait_for module  in  order to check the services by
login to server. Also can we set different timeout values for different
host in wait_for module.Can you please throw some light as i am created a
playbook for reboot and calling it in other playbook by specifying specific
host. like below but its not working .

---
 tasks:
   shell: sleep 2 && shutdown -r now
   async: 1
   poll: 0
   ignore_errors: true

server.yml

---
- name: for the individual hosts
- hosts: 192.168.3.154 <( This server requires to wait for the
server to come online after reboot )
  tasks:
   include: tasks/restart1.yml
   - name: wait for the server to be online
 local_action: wait_for host={{ inventory_hostname }} state=started
delay=5 timeout=120

- hosts: 192.168.3.153 < ( this server doesnot require to wait
for the server to come back after reboot )
  tasks:
   - include: tasks/restart1.yml


But its giving me the syntax errors including error of duplicate tasks etc.

Thanks for helping



On Tue, Nov 7, 2017 at 11:20 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 07. nov. 2017 18:22, coach rhca wrote:
> > Thanks Kai , looking for something like the server is rebooted and looks
> > for the processes or service and then move to the next server reboots and
> > check the service and goes to  the next hosts and does the same.
>
> You can do something like this.
>
>   - shell: sleep 2 && /sbin/shutdown -r now
> async: 1
> poll: 0
>
>   - wait_for:
>   port: 22
>   host: '{{ inventory_hostname }}'
>   search_regex: OpenSSH
>   delay: 10
> delegate_to: localhost
>
>   - service:
>   name: service-name
>   state: started
> check_mode: yes
> register: r
>
>   - fail:
>   msg: Something went wrong
> when: r.state != 'started'
>
>
> But if your process is listening on a port that you can check, then you
> can use wait_for directly.
>
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/5UvPWbQGyT4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/400495c5-da75-5922-2e2a-9e07773cb68c%40olstad.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALguqPK04q6TkUzNbmTacUk6cjMoDKT-aO-LOrvHyzspQ4m%2Bkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] passing --ask-become-pass to task within playbook

2017-11-07 Thread Kai Stian Olstad

On 07.11.2017 23:12, Stephen Tyler wrote:

If I have a playbook with -b --become-user=root --ask-become-pass CLI
arguments.. and a script/task that cannot be started with root (so I 
can't
use become on a task level) but later asks to sudo, to be able to pass 
the

ask-become-pass to the task?

The  script i'm referring to is makepkg -
https://wiki.archlinux.org/index.php/makepkg


I don't think there is a way to get the password from the 
ask-become-pass.
It could be considered a potential security issue if that where 
possible.


When you have script asking for information that you can't provide with 
command line arguments you can use the expect module.
And the password need to be provided somehow, some of the options are 
hard code it, use vars_prompt, put it in a variable, use one of the 
supported password managers



--
Kai Stian Olstad

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e5f72b548bb61a7ffd45176ed8c47370%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How do you register variables from imported playbooks?

2017-11-07 Thread Brian Coca
You are getting an error because you are passing a string, the
'register' keyword is 'host specific' since the host in both plays is
'localhost' it is directly accessible, you should have:


vpc_subnet_id: "{{public_subnet}}"



-- 
--
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7eh0eMzkC_DE9ej8ki8h%2BGLvjuuM99fAZ08CQEg%3Dk%2BREA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Modifying local files while targeting a remote system

2017-11-07 Thread EspressoBeanies
Thanks Kai

On Tuesday, November 7, 2017 at 2:19:48 PM UTC-5, Kai Stian Olstad wrote:
>
> On 07. nov. 2017 20:12, EspressoBeanies wrote: 
> > Is it possible to modify local files while targeting a remote system in 
> an 
> > Ansible YAML file? I'm trying to run an Ansible script on a remote 
> machine, 
> > but when everything finishes on that remote machine, I'd like to move 
> that 
> > hostname from one Ansible hosts file to another. Is it possible and if 
> so, 
> > could someone point me in the right direction? Thanks! 
>
>
> On all task you can use delegate_to[1] and that task will run on the 
> delegated machine. 
> So "delegate_to: localhost" will run on local machine and not on the 
> remote host. 
>
> To change a file you have the lineinfile module or the template module. 
>
>
> [1] 
> https://docs.ansible.com/ansible/latest/playbooks_delegation.html#delegation 
>
> -- 
> Kai Stian Olstad 
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bdcbdfff-1824-4e78-b137-cfe08a81bfdb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] passing --ask-become-pass to task within playbook

2017-11-07 Thread Stephen Tyler
Hello.

If I have a playbook with -b --become-user=root --ask-become-pass CLI 
arguments.. and a script/task that cannot be started with root (so I can't 
use become on a task level) but later asks to sudo, to be able to pass the 
ask-become-pass to the task?

The  script i'm referring to is makepkg - 
https://wiki.archlinux.org/index.php/makepkg

Any suggestions?

Best,
-Stephen

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9fc52535-b582-4c9d-a292-74145dd9d47f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] regexp multiline

2017-11-07 Thread Dick Visser
There are currently only two flags available for use in regular
expression filters in ansible, which appear to be 'ignorecase' and
'multiline':

https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/filter/core.py

You're not entirely bound by these restrictions, because it's possible
to set flags by having your expression start with them:

https://docs.python.org/2/library/re.html (at the 'iLmsux' header).

DIck


On 6 November 2017 at 23:09, John Harmon  wrote:
> I can muddle through regexp on a regex tester, but when I import it to
> ansible it bombs.  Is there a way to set flags, such as multiline under
> ansible?  Or am I writing this completely wrong?  Basically I am trying to
> fine this line as long as it isn't commented out:
>
> ^(?!#).*soft.*nofile.*
>
> Sample limits.conf:
> #* soft nofile 4096
> * soft nofile 50
> #* hard nofile 65535
> * hard nofile 50
> * soft nproc 16384
> * hard nproc 65535
> * soft stack 4096
> * hard stack 65535
> * soft memlock 17384000
> * hard memlock 17384000
>
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/585dc03e-e33a-4d68-b717-0a7d7a9fe969%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Dick Visser
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwOQ5%2BgNZ9mpGdxPFzxUG283_qGyTso-%3D0TMGuqnGf_3ag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: fatal: [localhost]: FAILED! when installing IIS on Windows Server 2016 ec2

2017-11-07 Thread Akim Grudzitsky
OMG! Guys, thank you SO much!!!
I appreciate your help.


On Tuesday, November 7, 2017 at 3:00:48 PM UTC-5, Jordan Borean wrote:
>
> As Jon is saying you are trying to run the win_feature module on localhost 
> and not the newly provisioned EC2 server. Here is a very mock playbook that 
> you need to follow to get working. Note this is not tested and some things 
> could potentially be wrong
>
> ---
> - name: provision new EC2 server
>   hosts: localhost
>   gather_facts: no
>   tasks:
>   - name: provision t2.micro EC2 instance
> 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
> register: ec2_details
>
>
>   - name: add new t2.micro EC2 instance to Windows group
> add_host:
>   name: '{{item.public_ip}}'
>   groups: windows
> with_items: '{{ec2_details.instances}}'
>
>
> - name: install features on new EC2 server
>   hosts: windows
>   gather_facts: no
>   tasks:
>   - name: wait for connection to be online
> wait_for_connection:
>
>   - name: install IIS Web-Server with sub features and management tools
> win_feature:
>   name: Web-Server
>   state: present
>   include_sub_features: yes
>   include_management_features: yes
> register: feature_install
>
>
>   - name: reboot if feature install requires it
> win_reboot:
> when: feature_install.reboot_required
>
> Just a few notes about this
>
> * Your inventory should contain an empty group calls *windows* that 
> contains the connection vars required for it to connect. After provisioning 
> the EC2 instance, *add_host *will add the public IP of the newly created 
> instances to that group for the next play to work
> * The 2nd play which runs on the windows group will first wait for the 
> connection to be online, this will actively try and connect over WinRM and 
> will fail if that is unsuccessful after a timeout
> * The *restart* option of win_feature is deprecated, I've split it out 
> into 2 tasks using the win_reboot action plugin.
>
> Thanks
>
> Jordan
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0835737e-35a4-42b6-bc98-6ea8030364ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: fatal: [localhost]: FAILED! when installing IIS on Windows Server 2016 ec2

2017-11-07 Thread Jordan Borean
As Jon is saying you are trying to run the win_feature module on localhost 
and not the newly provisioned EC2 server. Here is a very mock playbook that 
you need to follow to get working. Note this is not tested and some things 
could potentially be wrong

---
- name: provision new EC2 server
  hosts: localhost
  gather_facts: no
  tasks:
  - name: provision t2.micro EC2 instance
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
register: ec2_details


  - name: add new t2.micro EC2 instance to Windows group
add_host:
  name: '{{item.public_ip}}'
  groups: windows
with_items: '{{ec2_details.instances}}'


- name: install features on new EC2 server
  hosts: windows
  gather_facts: no
  tasks:
  - name: wait for connection to be online
wait_for_connection:

  - name: install IIS Web-Server with sub features and management tools
win_feature:
  name: Web-Server
  state: present
  include_sub_features: yes
  include_management_features: yes
register: feature_install


  - name: reboot if feature install requires it
win_reboot:
when: feature_install.reboot_required

Just a few notes about this

* Your inventory should contain an empty group calls *windows* that 
contains the connection vars required for it to connect. After provisioning 
the EC2 instance, *add_host *will add the public IP of the newly created 
instances to that group for the next play to work
* The 2nd play which runs on the windows group will first wait for the 
connection to be online, this will actively try and connect over WinRM and 
will fail if that is unsuccessful after a timeout
* The *restart* option of win_feature is deprecated, I've split it out into 
2 tasks using the win_reboot action plugin.

Thanks

Jordan

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fe9eae43-8157-4ea0-8d9b-3eb3d84529a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Modifying local files while targeting a remote system

2017-11-07 Thread Kai Stian Olstad
On 07. nov. 2017 20:12, EspressoBeanies wrote:
> Is it possible to modify local files while targeting a remote system in an
> Ansible YAML file? I'm trying to run an Ansible script on a remote machine,
> but when everything finishes on that remote machine, I'd like to move that
> hostname from one Ansible hosts file to another. Is it possible and if so,
> could someone point me in the right direction? Thanks!


On all task you can use delegate_to[1] and that task will run on the delegated 
machine.
So "delegate_to: localhost" will run on local machine and not on the remote 
host.

To change a file you have the lineinfile module or the template module.


[1] https://docs.ansible.com/ansible/latest/playbooks_delegation.html#delegation

-- 
Kai Stian Olstad

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8087cc10-2712-f6fa-0aaa-291f7cf14781%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Modifying local files while targeting a remote system

2017-11-07 Thread EspressoBeanies
Is it possible to modify local files while targeting a remote system in an 
Ansible YAML file? I'm trying to run an Ansible script on a remote machine, 
but when everything finishes on that remote machine, I'd like to move that 
hostname from one Ansible hosts file to another. Is it possible and if so, 
could someone point me in the right direction? Thanks!

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/006372d4-5eaf-41fa-931b-18d60e2120fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Errativ behavior when looping over a fileglob

2017-11-07 Thread Kai Stian Olstad
On 07. nov. 2017 19:21, Marc Haber wrote:
> Hi,
> 
> I am trying to remove a bunch of files wiht the following code:
> 
> $ cat site.yml
> ---
> - name: apply common configuration
>hosts: all
>remote_user: root
>become: "yes"
>roles:
>  - common
> $ cat roles/common/tasks/repos.yml
> ---
> - name: remove extra files that may be on the systems
>file:
>  path: "{{ item }}"
>  state: absent
>with_fileglob:
>  - "/etc/apt/sources.list.d/zda-*.list"
>  - "/etc/apt/sources.list.d/exp-mc.list"
>  - "/etc/apt/sources.list.d/sid-mc.list"
>  - "/etc/apt/sources.list.d/sid-zg-stable-mc.list"
>  - "/etc/apt/sources.list.d/sid-zg-unstable-mc.list"
>  - "/etc/apt/sources.list.d/stretch-mc.list"
>  - "/etc/apt/sources.list.d/stretch-security.list"
>  - "/etc/apt/sources.list.d/stretch-zg-stable-mc.list"
>  - "/etc/apt/sources.list.d/stretch-zg-unstable-mc.list"
>  - "/etc/apt/sources.list.d/buster-mc.list"
>  - "/etc/apt/sources.list.d/stretch-zg-stable-mc.list"
>  - "/etc/apt/sources.list.d/stretch-security.list"
>  - "/etc/apt/preferences.d/??-zda-*.pref"
>  - "/etc/apt/preferences.d/10-sid-zg-unstable-mc.pref"
>  - "/etc/apt/preferences.d/20-sid-zg-stable-mc.pref"
>  - "/etc/apt/preferences.d/50-sid-security.pref"
>  - "/etc/apt/preferences.d/70-sid.pref"
>  - "/etc/apt/preferences.d/99-default.pref"
> - name: include repositories
>tags:
>repos
>include_tasks:
>"{{distribution}}/{{distribution_version}}/repos.yml"
> $
> 
> My target system contains the following files:
> -rw-r--r-- 1 root root0 Nov  7 19:06 zda-foo.list
> -rw-r--r-- 1 root root   63 Nov  7 19:03 zda-sid-mc.list
> -rw-r--r-- 1 root root   75 Nov  7 19:03 zda-sid-zg-stable-mc.list
> -rw-r--r-- 1 root root   77 Nov  7 19:03 zda-sid-zg-unstable-mc.list
> 
> Running the playbook tries to remove two files that are not there but
> leaves the files in place:


with_fileglob is a lookup plugin, and lookup plugin runs on the Ansible 
controller and not the remote host.

To do what what you want to do, you must use the find module to find the files 
and register the output in a variable.
Then you can delete them with the file module and with_items.


-- 
Kai Stian Olstad

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/efe443fe-eb65-f92e-4b59-2f9d73a6c2f6%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Errativ behavior when looping over a fileglob

2017-11-07 Thread Marc Haber
Hi,

I am trying to remove a bunch of files wiht the following code:

$ cat site.yml
---
- name: apply common configuration
  hosts: all
  remote_user: root
  become: "yes"
  roles:
- common
$ cat roles/common/tasks/repos.yml
---
- name: remove extra files that may be on the systems
  file:
path: "{{ item }}"
state: absent
  with_fileglob:
- "/etc/apt/sources.list.d/zda-*.list"
- "/etc/apt/sources.list.d/exp-mc.list"
- "/etc/apt/sources.list.d/sid-mc.list"
- "/etc/apt/sources.list.d/sid-zg-stable-mc.list"
- "/etc/apt/sources.list.d/sid-zg-unstable-mc.list"
- "/etc/apt/sources.list.d/stretch-mc.list"
- "/etc/apt/sources.list.d/stretch-security.list"
- "/etc/apt/sources.list.d/stretch-zg-stable-mc.list"
- "/etc/apt/sources.list.d/stretch-zg-unstable-mc.list"
- "/etc/apt/sources.list.d/buster-mc.list"
- "/etc/apt/sources.list.d/stretch-zg-stable-mc.list"
- "/etc/apt/sources.list.d/stretch-security.list"
- "/etc/apt/preferences.d/??-zda-*.pref"
- "/etc/apt/preferences.d/10-sid-zg-unstable-mc.pref"
- "/etc/apt/preferences.d/20-sid-zg-stable-mc.pref"
- "/etc/apt/preferences.d/50-sid-security.pref"
- "/etc/apt/preferences.d/70-sid.pref"
- "/etc/apt/preferences.d/99-default.pref"
- name: include repositories
  tags:
  repos
  include_tasks:
  "{{distribution}}/{{distribution_version}}/repos.yml"
$

My target system contains the following files:
-rw-r--r-- 1 root root0 Nov  7 19:06 zda-foo.list
-rw-r--r-- 1 root root   63 Nov  7 19:03 zda-sid-mc.list
-rw-r--r-- 1 root root   75 Nov  7 19:03 zda-sid-zg-stable-mc.list
-rw-r--r-- 1 root root   77 Nov  7 19:03 zda-sid-zg-unstable-mc.list

Running the playbook tries to remove two files that are not there but
leaves the files in place:

$ ansible-playbook --inventory=hosts.yml --limit=emptysid86 site.yml

PLAY [apply common configuration]

TASK [Gathering Facts]
ok: [emptysid86]

TASK [common : remove extra files that may be on the systems]
ok: [emptysid86] => (item=/etc/apt/sources.list.d/sid-zg-stable-mc.list)
ok: [emptysid86] => (item=/etc/apt/sources.list.d/sid-zg-unstable-mc.list)

When I replace with_fileglob with with_items in the tasks file, it
removes the files that are explicitly given, but of course doesn't glob,
so the /etc/apt/sources.lists.d/zda-*.list doesn't work.

What am I doing wrong?

Greetings
Marc

-- 
-
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany|  lose things."Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20171107182148.qokzeko4gndtgzth%40torres.zugschlus.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] wait_for module

2017-11-07 Thread Kai Stian Olstad
On 07. nov. 2017 18:22, coach rhca wrote:
> Thanks Kai , looking for something like the server is rebooted and looks
> for the processes or service and then move to the next server reboots and
> check the service and goes to  the next hosts and does the same.

You can do something like this.

  - shell: sleep 2 && /sbin/shutdown -r now
async: 1
poll: 0

  - wait_for:
  port: 22
  host: '{{ inventory_hostname }}'
  search_regex: OpenSSH
  delay: 10
delegate_to: localhost

  - service:
  name: service-name
  state: started
check_mode: yes
register: r

  - fail:
  msg: Something went wrong
when: r.state != 'started' 


But if your process is listening on a port that you can check, then you can use 
wait_for directly.


-- 
Kai Stian Olstad

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/400495c5-da75-5922-2e2a-9e07773cb68c%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] wait_for module

2017-11-07 Thread coach rhca
Thanks Kai , looking for something like the server is rebooted and looks
for the processes or service and then move to the next server reboots and
check the service and goes to  the next hosts and does the same.

On Mon, Nov 6, 2017 at 8:51 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 06. nov. 2017 06:52, coach.r...@gmail.com wrote:
> > After rebooting the host and need to check if that process is back
> online.
> > Is there a way in ansible (or "wait_for module" ) to check the service or
> > process to be running after a reboot. could you please share your insight
> > about it.Thank you..
>
>
> For the reboot you can use
>
> - name: Restart server
>   shell: sleep 2 && /sbin/shutdown -r now
>   async: 1
>   poll: 0
>
>
> If you can use wait_for depends on what your process is doing,
> wait_for can do many things you find it in the documentation[1].
>
> To check if a service is running you have service module that can do that.
>
>
> [1] https://docs.ansible.com/ansible/latest/wait_for_module.html
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/5UvPWbQGyT4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/00af81da-be7e-a516-35dc-96078bd0b734%40olstad.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALguqPLg_UDYKeezGk2aMtomkVHnZYDtK5Yan3wchtuWC8_u%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] how to get only and only command output in ansible playbook

2017-11-07 Thread Sameer Modak
Hello Team,

Whenever i run my playbook, it gives me below output which i do not want i 
just want standard output or standard error.

---
- hosts: all
  remote_user: ansible
  become: yes
  become_method: sudo
  gather_facts: no
  tasks:
  - name: dislpyname
command: /usr/bin/subscription-manager status
register: out
  - debug: var=out.stderr
~










Now for below i just want "Error updating system data on the server, see 
/var/log/rhsm/rhsm.log for more details." nothing else.

fatal: [pdc2lodbk01.baf.ikano]: FAILED! => {"changed": true, "cmd": 
["/usr/bin/subscription-manager", "status"], "delta": "0:00:09.188844", 
"end": "2017-11-07 17:23:13.859596", "failed": true, "rc": 1, "start": 
"2017-11-07 17:23:04.670752", "stderr": "", "stderr_lines": [], "stdout": 
"+---+\n   System Status 
Details\n+---+\nOverall Status: 
Unknown", "stdout_lines": ["+---+", 
"   System Status Details", 
"+---+", "Overall Status: Unknown"]}


fatal: [uvdclasx137.baf.ikano]: FAILED! => {"changed": true, "cmd": 
["/usr/bin/subscription-manager", "status"], "delta": "0:02:06.338207", 
"end": "2017-11-07 17:19:25.150107", "failed": true, "rc": 70, "start": 
"2017-11-07 17:17:18.811900", "stderr": "Error updating system data on the 
server, see /var/log/rhsm/rhsm.log for more details.", "stderr_lines": 
["Error updating system data on the server, see /var/log/rhsm/rhsm.log for 
more details."], "stdout": "", "stdout_lines": []}
fatal: [uvdclasx138.baf.ikano]: FAILED! => {"changed": true, "cmd": 
["/usr/bin/subscription-manager", "status"], "delta": "0:02:06.303761", 
"end": "2017-11-07 17:19:27.735012", "failed": true, "rc": 70, "start": 
"2017-11-07 17:17:21.431251", "stderr": "Error updating system data on the 
server, see /var/log/rhsm/rhsm.log for more details.", "stderr_lines": 
["Error updating system data on the server, see /var/log/rhsm/rhsm.log for 
more details."], "stdout": "", "stdout_lines": []}
fatal: [uvdclasx187.baf.ikano]: FAILED! => {"changed": true, "cmd": 
["/usr/bin/subscription-manager", "status"], "delta": "0:01:03.324022", 
"end": "2017-11-07 17:19:28.245675", "failed": true, "rc": 70, "start": 
"2017-11-07 17:18:24.921653", "stderr": "Error updating system data on the 
server, see /var/log/rhsm/rhsm.log for more details.", "stderr_lines": 
["Error updating system data on the server, see /var/log/rhsm/rhsm.log for 
more details."], "stdout": "", "stdout_lines": []}

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/af89da6d-1978-4893-81ba-3eb729c469c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: fatal: [localhost]: FAILED! when installing IIS on Windows Server 2016 ec2

2017-11-07 Thread Akim Grudzitsky
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'
>>
>> 

Re: [ansible-project] Maximum Failure Percentage - global setting

2017-11-07 Thread Kai Stian Olstad

On 07.11.2017 12:25, Jonathan Nuñez Aguin wrote:

I have multiple plays where we need to fail when one of the host has a
failure, behaviour that we can configure by using "max_fail_percentage: 
0"
but we need to add this setting in each play which is really verbose 
and
prone to errors if the developer miss it in a new play. Is there a way 
of

setting up "max_fail_percentage" in the Ansible CFG or globally?


I don't think you can set max_fail_percentage, but you can set 
any_errors_fatal to true


http://docs.ansible.com/ansible/latest/config.html#any-errors-fatal

--
Kai Stian Olstad

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f385bcf8245ee67c639162bb9841dc98%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] tower surveys / how to enter a per host variable value

2017-11-07 Thread Kai Stian Olstad

On 07.11.2017 10:31, Ulises Alonso wrote:

Hi all again

I don't see it is possible to enter a variable value different for each
host when using ansible tower surveys

Is it not possible?



This is the list for Ansible not Tower.

Please contact RedHat support for Tower questions / issues.


--
Kai Stian Olstad

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ec26f72c8b2512ef54664f5787bb9b00%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Maximum Failure Percentage - global setting

2017-11-07 Thread Jonathan Nuñez Aguin
Hello,

I have multiple plays where we need to fail when one of the host has a 
failure, behaviour that we can configure by using "max_fail_percentage: 0" 
but we need to add this setting in each play which is really verbose and 
prone to errors if the developer miss it in a new play. Is there a way of 
setting up "max_fail_percentage" in the Ansible CFG or globally?

Thanks!

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2d6d0d0c-eb68-4291-9700-19770ee2c7fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Hi, can someone help me please ? it's about docker_image is not pushing to docker hub

2017-11-07 Thread Arkan M Gerges Anabi
Hi guys,

I'm trying for more than 2 days to make this work, I'm using jenkins with 
ansible. My ansible role is like this:

- name: Login into docker hub
  docker_login:
username: "username"
password: "pass"
email: "me@myemail"
docker_host: "192.168.99.100"
tls: true
cert_path: "path to docker certificate"
key_path: "path to docker key"

- name: Register image to docker hub
  docker_image:
name: "username/myimagename"
repository: "username/myimagename"
push: yes
tag: "1.0.1"
docker_host: "192.168.99.100"
tls: true
cert_path: "path to docker certificate"
key_path: "path to docker key"


the problem is, the above code succeeds but it does not push the image to 
my docker hub account.

I'm having windows 10, running ansible from a jenkins that is running 
inside docker container, the docker container has ansible installed also. 
Docker is installed inside windows 10, and it's api is 192.168.99.100, and 
from there I can push the image manually and it will work,
but with ansible with docker_image module I could not do it.

The full output from jenkins is like this:

Started by user Arkan M. Gerges Anabi 
ln -s builds/lastSuccessfulBuild /var/jenkins_home/jobs/ANIM-RAL-Pipeline --- 
Real Actor Limitation Pipeline/lastSuccessful failed: 71 Protocol error
ln -s builds/lastStableBuild /var/jenkins_home/jobs/ANIM-RAL-Pipeline --- Real 
Actor Limitation Pipeline/lastStable failed: 71 Protocol error[Pipeline] 
nodeRunning on Jenkins  in 
/var/jenkins_home/workspace/ANIM-RAL-Pipeline --- Real Actor Limitation 
Pipeline[Pipeline] {[Pipeline] stage[Pipeline] { (Image Registration)[Pipeline] 
withCredentials[Pipeline] {[Pipeline] withCredentials[Pipeline] {[Pipeline] 
sh[ANIM-RAL-Pipeline --- Real Actor Limitation Pipeline] Running shell script
+ cd /ansible/erl_real_actor_limitation
+ ansible-playbook app/app.yml -i inventory.jenkins --extra-vars 
DOCKER_REPO_EMAIL= DOCKER_REPO_USERNAME= DOCKER_REPO_PASSWORD= 
APP_TAG=1.0.1 --tags register -vvv
ansible-playbook 2.4.1.0
  config file = /ansible/erl_real_actor_limitation/ansible.cfg
  configured module search path = [u'/home/jenkins/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]
Using /ansible/erl_real_actor_limitation/ansible.cfg as config file
Parsed /ansible/erl_real_actor_limitation/inventory.jenkins inventory source 
with ini plugin

PLAYBOOK: app.yml **
1 plays in app/app.yml

PLAY [Continous Delivery for real_actor_limitation] 

TASK [Gathering Facts] *
Using module file 
/usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<192.168.0.32> ESTABLISH SSH CONNECTION FOR USER: arkan
<192.168.0.32> SSH: EXEC sshpass -d10 ssh -o ControlMaster=no -o 
ControlPersist=60s -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o 
StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o Port=22 -o User=arkan 
-o ConnectTimeout=10 -o ControlPath=/home/jenkins/.ansible/cp/12be3575c6 
192.168.0.32 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<192.168.0.32> (0, '/home/arkan\n', "Warning: Permanently added '192.168.0.32' 
(ECDSA) to the list of known hosts.\r\n")
<192.168.0.32> ESTABLISH SSH CONNECTION FOR USER: arkan
<192.168.0.32> SSH: EXEC sshpass -d10 ssh -o ControlMaster=no -o 
ControlPersist=60s -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o 
StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o Port=22 -o User=arkan 
-o ConnectTimeout=10 -o ControlPath=/home/jenkins/.ansible/cp/12be3575c6 
192.168.0.32 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo 
/home/arkan/.ansible/tmp/ansible-tmp-1510047574.27-167135549000441 `" && echo 
ansible-tmp-1510047574.27-167135549000441="` echo 
/home/arkan/.ansible/tmp/ansible-tmp-1510047574.27-167135549000441 `" ) && 
sleep 0'"'"''
<192.168.0.32> (0, 
'ansible-tmp-1510047574.27-167135549000441=/home/arkan/.ansible/tmp/ansible-tmp-1510047574.27-167135549000441\n',
 "Warning: Permanently added '192.168.0.32' (ECDSA) to the list of known 
hosts.\r\n")
<192.168.0.32> PUT /tmp/tmpvDxEWu TO 
/home/arkan/.ansible/tmp/ansible-tmp-1510047574.27-167135549000441/setup.py
<192.168.0.32> SSH: EXEC sshpass -d10 sftp -o BatchMode=no -b - -o 
ControlMaster=no -o ControlPersist=60s -o ForwardAgent=yes -o 
UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o 
StrictHostKeyChecking=no -o Port=22 -o User=arkan -o ConnectTimeout=10 -o 
ControlPath=/home/jenkins/.ansible/cp/12be3575c6 '[192.168.0.32]'
<192.168.0.32> (0, 'sftp> put /tmp/tmpvDxEWu 

[ansible-project] Re: Win_command module adds an additional slash to the windows path.

2017-11-07 Thread 'J Hawkesworth' via Ansible Project
You don't mention which ansible version you are using, but I think latest 
devel version and possible 2.4.1 has some improvements to argument handling 
for win command.

If you are using an older ansible version, I suggest trying win_shell.  
 Make sure groovy is on your PATH (or use the args: chdir option of 
win_command / win_shell so that the command itself can be found too).

There's a very useful page about how to form windows paths in yaml for 
ansible playbooks recently been added to the documentation 
here: 
https://docs.ansible.com/ansible/devel/windows_usage.html#path-formatting-for-windows

Hope this helps,

Jon

On Monday, November 6, 2017 at 10:30:02 AM UTC, anoop vc wrote:
>
> Please find my YAML below
>
>
> ***
> ---
> - hosts: all
>   vars:
>   tasks:
>   - name: Save the result of 'whoami' in 'whoami_out'
> win_command: groovy c:\AnsibletestWorkspace\deploy_latest.groovy
> register: whoami_out
>
>
> 
>
> It adds an additional 
> slash(c:\\AnsibleMaximoWorkspace\\deploy_latest.groovy) to the windows path 
> the tell cannot find the path specified. I tried with backslash then it's 
> not add the double slash but still trown the error path to the file not 
> found. 
>
> I tried all the different combinations for specfy the path but no luck. 
>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5629b53d-7064-4df0-9ea7-5a12f8e36220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: fatal: [localhost]: FAILED! when installing IIS on Windows Server 2016 ec2

2017-11-07 Thread 'J Hawkesworth' via Ansible Project

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 

[ansible-project] Re: Get user details

2017-11-07 Thread Soniya panwar
hello,

Yes, you can get available users or user details in system by using ansible 
playbooks. For this you need to use the command / win_command module. 
"The command module takes the command name followed by a list of 
space-delimited arguments and executes the given command on all selected 
nodes."

If  you are trying to retrieve user or user details on a linux system, you 
may use below playbooks: 

1. To get available users in system 

   - name: get available users in system
 command: cut -d: -f1 /etc/passwd
 register: AvailableUsers

  - debug: msg="{{ AvailableUsers.stdout }}"

2. To get a spcific user details.

   - name: get specific user details in system
 command: id username
 register: SpecificUserDetails

- debug: msg="{{ SpecificUserDetails.stdout }}"


If  you are trying to retrieve user or user details on a windows system, 
you may use below playbooks: 

1. To get available users in system 

   - name: get available users in system
 win_command: net user 
 register: AvailableUsers

  - debug: msg="{{ AvailableUsers.stdout }}"

2. To get a spcific user details.

   - name: get specific user details in system
 win_command: net user  username
 register: SpecificUserDetails

- debug: msg="{{ SpecificUserDetails.stdout }}"

Thanks
Soniya


On Thursday, November 2, 2017 at 4:39:14 PM UTC+5:30, Ravikumar Wagh wrote:
>
> Is there any way to get available users in system or an spcific user 
> details.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/deffcfb4-ab3e-43a8-9044-569ef5f147dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.