Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread Vladimir Botka
On Tue, 9 Jun 2020 06:27:41 +0200
Dick Visser  wrote:

> OK... and what would you DO with this information..?

Nothing. Why are you asking?

-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200609075149.72c47203%40gmail.com.


pgpXcI8w60RIc.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread Dick Visser
OK... and what would you DO with this information..?

On Mon, 8 Jun 2020 at 23:52, vinay kumar  wrote:

> Hello @all
> Let me elaborate the question
>
> I have 20 services to check and I would like to execute shell module one
> time and register its output and match the service name and its status from
> output lines.
>
> for ex: I dont want to use grep in shell module for service name I want to
> get the status from registered output by matching the lines
>shell: systemctl list-unit-files --all --state=disabled,enabled,unknown
> --no-legend --no-pager
>register: _service_status
>
> I want to verify the service name and status with when condition from the
> _service_status.stdout lines
> ex:
> comment: "tftp service is in enabled"
> when: _service_name _expected_state in service_status
>
> comment: "httpd service is in disabled"
> when: _service_name _current_state in service_status
>
>
> variables listed is mentioned in defaults/vars:
>
> service_name: tftp
> expected_state: enable
>
> service_name: httpd
> current: disable
>
> On Mon, Jun 8, 2020 at 5:12 PM Vladimir Botka  wrote:
>
>> On Mon, 8 Jun 2020 13:55:42 -0700 (PDT)
>> vinay kumar  wrote:
>>
>> > ... search in when condition two strings from single line
>> > 1: httpd  disabled
>> > 2: tftp enabled
>>
>> For example
>>
>> - debug:
>> var: item
>>   loop: "{{ output.stdout_lines }}"
>>   when:
>> - "'httpd' in item"
>> - "'disabled' in item"
>>
>> should give
>>
>>   ok: [localhost] => (item=1: httpd  disabled) => {
>>   "ansible_loop_var": "item",
>>   "item": "1: httpd  disabled"
>>   }
>>   skipping: [localhost] => (item=2: tftp   enabled)
>>
>>
>> --
>> Vladimir Botka
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAEMXqfvSrTzOqonpgvhK78PDjyjsVsknH_jnmjGmd-wxD7RoDQ%40mail.gmail.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwO3xKffXvZ-jCSJumbtr8BRWmCv1wr2OnNjABSOjrtCoA%40mail.gmail.com.


Re: [ansible-project] ansible playbook not printing the error message when disk is not defined

2020-06-08 Thread Dick Visser
Your playbook IS printing an error when the disk is not defined. See below

On Sun, 7 Jun 2020 at 15:59, Rajesh  wrote:

> Hi all,
>
> The below playbook is not printing an error message when the disk is not
> defined on a host. Could you please advise if I have made an mistake in the
> playbook. Thanks
>
> - name: Create a partition
>   hosts: all
>   become: true
>   become_user: root
>   tasks:
>- name: Gather disk info
>  parted:
> device: /dev/sdb
> unit: MB
>  register: device_info
>
>- name: Print disk info
>  debug:
>var: device_info
>
>- name: Create partition
>  parted:
>device: /dev/sdb
>number: 1
>part_start: 1MB
>part_end: 1200MB
>unit: MB
>state: present
>  when: device_info.disk.size > 1200
>
>- name: Print enough size is not available
>  debug:
>   msg: "Enough size is not available"
>  when: device_info.disk.size < 1200
>
>- name: Create 800MB partition
>  parted:
>device: /dev/sdb
>number: 1
>part_start: 1MB
>part_end: 800MB
>unit: MB
>state: present
>  when: device_info.disk.size < 1200
>
>- name: Create file system
>  filesystem:
> device: /dev/sdb1
> fstype: ext4
> force: yes
>
>- name: Create /exam directory
>  file:
> path: /exam
> state: directory
> owner: root
> group: root
> mode: '0755'
>
>- name: mount File system
>  mount:
>path: /exam
>src: /dev/sdb1
>fstype: ext4
>state: mounted
>
>- name: No extra hard disk
>  debug:
>   msg: "No extra hard disk available"
>  when: ansible_devices.sdb is undefined
>
>
> $ ansible-playbook partition.yml
>
> PLAY [Create a partition]
> **
>
> TASK [Gathering Facts]
> *
> ok: [ansible2.example.com]
> ok: [ansible4.example.com]
> ok: [ansible3.example.com]
>
> TASK [Gather disk info]
> 
> fatal: [ansible4.example.com]: FAILED! => {"changed": false, "err":
> "Error: Could not stat device /dev/sdb - No such file or directory.\n",
> "msg": "Error while getting device information with parted script:
> '/sbin/parted -s -m /dev/sdb -- unit 'MB' print'", "out": "", "rc": 1}
>

here



> ok: [ansible3.example.com]
> ok: [ansible2.example.com]
>
> TASK [Print disk info]
> *
> ok: [ansible2.example.com] => {
> "device_info": {
> "changed": false,
> "disk": {
> "dev": "/dev/sdb",
> "logical_block": 512,
> "model": "ATA VBOX HARDDISK",
> "physical_block": 512,
> "size": 12885.0,
> "table": "msdos",
> "unit": "mb"
> },
> "failed": false,
> "partitions": [
> {
> "begin": 1.05,
> "end": 1200.0,
> "flags": [],
> "fstype": "ext4",
> "name": "",
> "num": 1,
> "size": 1199.0,
> "unit": "mb"
> }
> ],
> "script": "unit 'MB' print"
> }
> }
> ok: [ansible3.example.com] => {
> "device_info": {
> "changed": false,
> "disk": {
> "dev": "/dev/sdb",
> "logical_block": 512,
> "model": "ATA VBOX HARDDISK",
> "physical_block": 512,
> "size": 1074.0,
> "table": "msdos",
> "unit": "mb"
> },
> "failed": false,
> "partitions": [
> {
> "begin": 1.05,
> "end": 800.0,
> "flags": [],
> "fstype": "ext4",
> "name": "",
> "num": 1,
> "size": 799.0,
> "unit": "mb"
> }
> ],
> "script": "unit 'MB' print"
> }
> }
>
> TASK [Create partition]
> 
> 

Re: [ansible-project] sudo(become) difference between "copy" module and "command" module

2020-06-08 Thread Mukuntha rajaa
Hello,

Which is why I've mentioned "become: yes" option. Like I've mentioned in
starting of this thread, if I run the exact same playbook with "command"
module, permission issue does not come. Only with "copy" module, it
complains about permission issue. Please note I've used "become" in both
the cases.

On Tue, 9 Jun, 2020, 6:57 am James Cassell, 
wrote:

>
> > On Mon, 8 Jun, 2020, 10:54 pm James Cassell,
> >  wrote:
> > >
> > >  On Mon, Jun 8, 2020, at 11:25 AM, Mukuntha rajaa wrote:
> > >  > Hello,
> > >  >
> > >  > "become" works perfectly fine with "command" module. But not with
> > >  > "copy" module. Am I doing something wrong here.
> > >  >
> > >  > *_Working playbook:_*
> > >  > - name: demo
> > >  > hosts: localhost
> > >  > tasks:
> > >  > - name: copy
> > >  > command: cp /etc/ssh/sshd_config /tmp/sshd_config
> > >  > become: yes
> > >  > - name: edit
> > >  > lineinfile:
> > >  > path: /tmp/sshd_config
> > >  > regexp: '^PermitRootLogin'
> > >  > line: "PermitRootLogin yes"
> > >  > become: yes
> > >  >
> > >  > working logs:
> > >  > $ ap lineinfile.yml
> > >  > [WARNING]: provided hosts list is empty, only localhost is
> available.
> > >  > Note that the implicit localhost does not match 'all'
> > >  >
> > >  > PLAY [demo]
> > >  >
> 
> > >  >
> > >  > TASK [Gathering Facts]
> > >  >
> *
> > >  > ok: [localhost]
> > >  >
> > >  > TASK [copy]
> > >  >
> 
> > >  > changed: [localhost]
> > >  >
> > >  > TASK [edit]
> > >  >
> 
> > >  > changed: [localhost]
> > >  >
> > >  > PLAY RECAP
> > >  >
> *
> > >  > localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0
> rescued=0
> > >  > ignored=0
> > >  >
> > >  >
> > >  > *_Problematic playbook:_*
> > >  > - name: demo
> > >  > hosts: localhost
> > >  > tasks:
> > >  > - name: copy
> > >  > copy:
> > >  > src: /etc/ssh/sshd_config
> > >  > dest: /tmp/sshd_config
> > >  > become: yes
> > >  > - name: edit
> > >  > lineinfile:
> > >  > path: /tmp/sshd_config
> > >  > regexp: '^PermitRootLogin'
> > >  > line: "PermitRootLogin yes"
> > >  > become: yes
> > >  >
> > >  > Logs for problematic playbook:
> > >  > $ap zz.yml
> > >  > [WARNING]: provided hosts list is empty, only localhost is
> available.
> > >  > Note that the implicit localhost does not match 'all'
> > >  >
> > >  > PLAY [demo]
> > >  >
> 
> > >  >
> > >  > TASK [Gathering Facts]
> > >  >
> *
> > >  > ok: [localhost]
> > >  >
> > >  > TASK [copy]
> > >  >
> 
> > >  > fatal: [localhost]: FAILED! => {"msg": "an error occurred while
> trying
> > >  > to read the file '/etc/ssh/sshd_config': [Errno 13] Permission
> denied:
> > >  > b'/etc/ssh/sshd_config'"}
> > >  >
> > >
> > >  You want `remote_src: yes`... otherwise it's trying to read the file
> from the controller.
>
>
> On Mon, Jun 8, 2020, at 8:27 PM, Mukuntha rajaa wrote:
> > Thanks for your email. This playbook is for testing purpose. I wanted
> > src to be from controller only.
> >
>
> In that case, you'll need to make sure the src file can be read by the
> user running ansible. sshd_config is not world readable by default.
>
> V/r,
> James Cassell
>
>
> > >
> > >  V/r,
> > >  James Cassell
> > >
> > >
> > >  > PLAY RECAP
> > >  >
> *
> > >  > localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0
> rescued=0
> > >  > ignored=0
> > >  >
> > >
>
> --
> 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/RQrthEhiPpo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f927-d1df-491f-b0fd-08b92b5dad93%40www.fastmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop 

Re: [ansible-project] sudo(become) difference between "copy" module and "command" module

2020-06-08 Thread James Cassell


> On Mon, 8 Jun, 2020, 10:54 pm James Cassell, 
>  wrote:
> > 
> >  On Mon, Jun 8, 2020, at 11:25 AM, Mukuntha rajaa wrote:
> >  > Hello,
> >  > 
> >  > "become" works perfectly fine with "command" module. But not with 
> >  > "copy" module. Am I doing something wrong here. 
> >  > 
> >  > *_Working playbook:_*
> >  > - name: demo
> >  > hosts: localhost
> >  > tasks:
> >  > - name: copy
> >  > command: cp /etc/ssh/sshd_config /tmp/sshd_config
> >  > become: yes
> >  > - name: edit
> >  > lineinfile:
> >  > path: /tmp/sshd_config
> >  > regexp: '^PermitRootLogin'
> >  > line: "PermitRootLogin yes"
> >  > become: yes
> >  > 
> >  > working logs:
> >  > $ ap lineinfile.yml
> >  > [WARNING]: provided hosts list is empty, only localhost is available. 
> >  > Note that the implicit localhost does not match 'all'
> >  > 
> >  > PLAY [demo] 
> >  > 
> > 
> >  > 
> >  > TASK [Gathering Facts] 
> >  > 
> > *
> >  > ok: [localhost]
> >  > 
> >  > TASK [copy] 
> >  > 
> > 
> >  > changed: [localhost]
> >  > 
> >  > TASK [edit] 
> >  > 
> > 
> >  > changed: [localhost]
> >  > 
> >  > PLAY RECAP 
> >  > 
> > *
> >  > localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 
> >  > ignored=0
> >  > 
> >  > 
> >  > *_Problematic playbook:_*
> >  > - name: demo
> >  > hosts: localhost
> >  > tasks:
> >  > - name: copy
> >  > copy:
> >  > src: /etc/ssh/sshd_config
> >  > dest: /tmp/sshd_config
> >  > become: yes
> >  > - name: edit
> >  > lineinfile:
> >  > path: /tmp/sshd_config
> >  > regexp: '^PermitRootLogin'
> >  > line: "PermitRootLogin yes"
> >  > become: yes
> >  > 
> >  > Logs for problematic playbook:
> >  > $ap zz.yml
> >  > [WARNING]: provided hosts list is empty, only localhost is available. 
> >  > Note that the implicit localhost does not match 'all'
> >  > 
> >  > PLAY [demo] 
> >  > 
> > 
> >  > 
> >  > TASK [Gathering Facts] 
> >  > 
> > *
> >  > ok: [localhost]
> >  > 
> >  > TASK [copy] 
> >  > 
> > 
> >  > fatal: [localhost]: FAILED! => {"msg": "an error occurred while trying 
> >  > to read the file '/etc/ssh/sshd_config': [Errno 13] Permission denied: 
> >  > b'/etc/ssh/sshd_config'"}
> >  > 
> > 
> >  You want `remote_src: yes`... otherwise it's trying to read the file from 
> > the controller.


On Mon, Jun 8, 2020, at 8:27 PM, Mukuntha rajaa wrote:
> Thanks for your email. This playbook is for testing purpose. I wanted 
> src to be from controller only.
> 

In that case, you'll need to make sure the src file can be read by the user 
running ansible. sshd_config is not world readable by default.

V/r,
James Cassell


> > 
> >  V/r,
> >  James Cassell
> > 
> > 
> >  > PLAY RECAP 
> >  > 
> > *
> >  > localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 
> >  > ignored=0
> >  > 
> > 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f927-d1df-491f-b0fd-08b92b5dad93%40www.fastmail.com.


[ansible-project] Re: ansible playbook not printing the error message when disk is not defined

2020-06-08 Thread Rajesh
Could someone please respond? Thanks

On Sunday, June 7, 2020 at 11:59:30 PM UTC+10, Rajesh wrote:
>
> Hi all,
>
> The below playbook is not printing an error message when the disk is not 
> defined on a host. Could you please advise if I have made an mistake in the 
> playbook. Thanks
>
> - name: Create a partition
>   hosts: all
>   become: true
>   become_user: root
>   tasks:
>- name: Gather disk info
>  parted:
> device: /dev/sdb
> unit: MB
>  register: device_info
>
>- name: Print disk info
>  debug:
>var: device_info
>
>- name: Create partition
>  parted: 
>device: /dev/sdb
>number: 1
>part_start: 1MB
>part_end: 1200MB
>unit: MB
>state: present
>  when: device_info.disk.size > 1200
>
>- name: Print enough size is not available
>  debug:
>   msg: "Enough size is not available"
>  when: device_info.disk.size < 1200
>
>- name: Create 800MB partition
>  parted: 
>device: /dev/sdb
>number: 1
>part_start: 1MB
>part_end: 800MB
>unit: MB
>state: present
>  when: device_info.disk.size < 1200
>
>- name: Create file system
>  filesystem:
> device: /dev/sdb1
> fstype: ext4
> force: yes
>
>- name: Create /exam directory
>  file:
> path: /exam
> state: directory
> owner: root
> group: root
> mode: '0755'
>
>- name: mount File system
>  mount:
>path: /exam
>src: /dev/sdb1
>fstype: ext4
>state: mounted
>
>- name: No extra hard disk
>  debug:
>   msg: "No extra hard disk available"
>  when: ansible_devices.sdb is undefined
>
>
> $ ansible-playbook partition.yml 
>
> PLAY [Create a partition] 
> **
>
> TASK [Gathering Facts] 
> *
> ok: [ansible2.example.com]
> ok: [ansible4.example.com]
> ok: [ansible3.example.com]
>
> TASK [Gather disk info] 
> 
> fatal: [ansible4.example.com]: FAILED! => {"changed": false, "err": 
> "Error: Could not stat device /dev/sdb - No such file or directory.\n", 
> "msg": "Error while getting device information with parted script: 
> '/sbin/parted -s -m /dev/sdb -- unit 'MB' print'", "out": "", "rc": 1}
> ok: [ansible3.example.com]
> ok: [ansible2.example.com]
>
> TASK [Print disk info] 
> *
> ok: [ansible2.example.com] => {
> "device_info": {
> "changed": false,
> "disk": {
> "dev": "/dev/sdb",
> "logical_block": 512,
> "model": "ATA VBOX HARDDISK",
> "physical_block": 512,
> "size": 12885.0,
> "table": "msdos",
> "unit": "mb"
> },
> "failed": false,
> "partitions": [
> {
> "begin": 1.05,
> "end": 1200.0,
> "flags": [],
> "fstype": "ext4",
> "name": "",
> "num": 1,
> "size": 1199.0,
> "unit": "mb"
> }
> ],
> "script": "unit 'MB' print"
> }
> }
> ok: [ansible3.example.com] => {
> "device_info": {
> "changed": false,
> "disk": {
> "dev": "/dev/sdb",
> "logical_block": 512,
> "model": "ATA VBOX HARDDISK",
> "physical_block": 512,
> "size": 1074.0,
> "table": "msdos",
> "unit": "mb"
> },
> "failed": false,
> "partitions": [
> {
> "begin": 1.05,
> "end": 800.0,
> "flags": [],
> "fstype": "ext4",
> "name": "",
> "num": 1,
> "size": 799.0,
> "unit": "mb"
> }
> ],
> "script": "unit 'MB' print"
> }
> }
>
> TASK [Create partition] 
> 
> skipping: 

Re: [ansible-project] sudo(become) difference between "copy" module and "command" module

2020-06-08 Thread Mukuntha rajaa
Thanks for your email. This playbook is for testing purpose. I wanted src
to be from controller only.

On Mon, 8 Jun, 2020, 10:54 pm James Cassell, 
wrote:

>
> On Mon, Jun 8, 2020, at 11:25 AM, Mukuntha rajaa wrote:
> > Hello,
> >
> > "become" works perfectly fine with "command" module. But not with
> > "copy" module. Am I doing something wrong here.
> >
> > *_Working playbook:_*
> > - name: demo
> >  hosts: localhost
> >  tasks:
> >  - name: copy
> >  command: cp /etc/ssh/sshd_config /tmp/sshd_config
> >  become: yes
> >  - name: edit
> >  lineinfile:
> >  path: /tmp/sshd_config
> >  regexp: '^PermitRootLogin'
> >  line: "PermitRootLogin yes"
> >  become: yes
> >
> > working logs:
> >  $ ap lineinfile.yml
> > [WARNING]: provided hosts list is empty, only localhost is available.
> > Note that the implicit localhost does not match 'all'
> >
> > PLAY [demo]
> >
> 
> >
> > TASK [Gathering Facts]
> >
> *
> > ok: [localhost]
> >
> > TASK [copy]
> >
> 
> > changed: [localhost]
> >
> > TASK [edit]
> >
> 
> > changed: [localhost]
> >
> > PLAY RECAP
> >
> *
> > localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0
> > ignored=0
> >
> >
> > *_Problematic playbook:_*
> > - name: demo
> >  hosts: localhost
> >  tasks:
> >  - name: copy
> >  copy:
> >  src: /etc/ssh/sshd_config
> >  dest: /tmp/sshd_config
> >  become: yes
> >  - name: edit
> >  lineinfile:
> >  path: /tmp/sshd_config
> >  regexp: '^PermitRootLogin'
> >  line: "PermitRootLogin yes"
> >  become: yes
> >
> > Logs for problematic playbook:
> > $ap zz.yml
> > [WARNING]: provided hosts list is empty, only localhost is available.
> > Note that the implicit localhost does not match 'all'
> >
> > PLAY [demo]
> >
> 
> >
> > TASK [Gathering Facts]
> >
> *
> > ok: [localhost]
> >
> > TASK [copy]
> >
> 
> > fatal: [localhost]: FAILED! => {"msg": "an error occurred while trying
> > to read the file '/etc/ssh/sshd_config': [Errno 13] Permission denied:
> > b'/etc/ssh/sshd_config'"}
> >
>
> You want `remote_src: yes`... otherwise it's trying to read the file from
> the controller.
>
> V/r,
> James Cassell
>
>
> > PLAY RECAP
> >
> *
> > localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0
> > ignored=0
> >
>
> --
> 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/RQrthEhiPpo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d437a90c-b2d0-4973-a5f2-701e301d8ac4%40www.fastmail.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD2erzfEcs0sznTFYOhe%2BCXs3Cqf6g13kHVAsmm8sVymHOCekA%40mail.gmail.com.


Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread vinay kumar
Hello @all
Let me elaborate the question

I have 20 services to check and I would like to execute shell module one
time and register its output and match the service name and its status from
output lines.

for ex: I dont want to use grep in shell module for service name I want to
get the status from registered output by matching the lines
   shell: systemctl list-unit-files --all --state=disabled,enabled,unknown
--no-legend --no-pager
   register: _service_status

I want to verify the service name and status with when condition from the
_service_status.stdout lines
ex:
comment: "tftp service is in enabled"
when: _service_name _expected_state in service_status

comment: "httpd service is in disabled"
when: _service_name _current_state in service_status


variables listed is mentioned in defaults/vars:

service_name: tftp
expected_state: enable

service_name: httpd
current: disable

On Mon, Jun 8, 2020 at 5:12 PM Vladimir Botka  wrote:

> On Mon, 8 Jun 2020 13:55:42 -0700 (PDT)
> vinay kumar  wrote:
>
> > ... search in when condition two strings from single line
> > 1: httpd  disabled
> > 2: tftp enabled
>
> For example
>
> - debug:
> var: item
>   loop: "{{ output.stdout_lines }}"
>   when:
> - "'httpd' in item"
> - "'disabled' in item"
>
> should give
>
>   ok: [localhost] => (item=1: httpd  disabled) => {
>   "ansible_loop_var": "item",
>   "item": "1: httpd  disabled"
>   }
>   skipping: [localhost] => (item=2: tftp   enabled)
>
>
> --
> Vladimir Botka
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEMXqfvSrTzOqonpgvhK78PDjyjsVsknH_jnmjGmd-wxD7RoDQ%40mail.gmail.com.


Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread Vladimir Botka
On Mon, 8 Jun 2020 13:55:42 -0700 (PDT)
vinay kumar  wrote:

> ... search in when condition two strings from single line
> 1: httpd  disabled
> 2: tftp enabled

For example

- debug:
var: item
  loop: "{{ output.stdout_lines }}"
  when:
- "'httpd' in item"
- "'disabled' in item"

should give

  ok: [localhost] => (item=1: httpd  disabled) => {
  "ansible_loop_var": "item",
  "item": "1: httpd  disabled"
  }
  skipping: [localhost] => (item=2: tftp   enabled)


-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200608231249.6395e01e%40gmail.com.


pgpHh5XiMdIM1.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread Dick Visser
What is your use case?
Could you tell us more what you are trying to achieve?

On Mon, 8 Jun 2020 at 22:55, vinay kumar  wrote:

> 1:
> Hello
> Is it possible to search in when condition two strings from single line by
> matching the registered output.
>
> For example:
>
> the registered output consists of services and its status
>
> 1: httpd  disabled
> 2: tftp enabled
>
> I want to search the line and use it in when condition.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/691b78e3-a9b9-4882-a133-a734e8f647cao%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwMCkeovWRP9RDHKgEYtfqiab5V%3DvMh3PsmsdQoEtdgAMA%40mail.gmail.com.


[ansible-project] Match two strings in when condition from registered output

2020-06-08 Thread vinay kumar
1: 
Hello
Is it possible to search in when condition two strings from single line by 
matching the registered output.

For example:

the registered output consists of services and its status

1: httpd  disabled
2: tftp enabled

I want to search the line and use it in when condition.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/691b78e3-a9b9-4882-a133-a734e8f647cao%40googlegroups.com.


Re: [ansible-project] While using j2 template and with_items i get the last item in o/p

2020-06-08 Thread Dick Visser
You are looping over the same template so that will only keep the last item.
Don't loop over the template, but instead use a loop inside your template.

On Mon, 8 Jun 2020 at 19:20, Rakesh Parida 
wrote:

> Hi
>
> my playbook is :
>- name: include vars
>  include_vars:
>file: /home/rparida1/content-var.yml
>
>- name: Testing
>  template:
>src: /home/rparida1/config.j2
>dest: /home/rparida1/test-raka222.properties
>  with_items:
>- "{{ Tenants }}"
>
> When i use the with_items, only the last item mentioned in my var file is
> displayed (my desired o/p is it should iterate through all the items
> mentioned in my var file):
>
> iam.biz.tenant.auth.connetion.timeout=1000
> iam.biz.tenant.auth.response.timeout=1000
> iam.biz.tenant.auth.retry.count=3
>
> iam.biz.tenant.auth.4231.host= test3
> iam.biz.tenant.auth.4231.authType=ldap1
> iam.biz.tenant.auth.4231.port=4433
> iam.biz.tenant.auth.4231.baseDN=ou=dfsd,ou=People21,o=xx.com
>
>
> I have a j2 template as follows:
> iam.biz.tenant.auth.connetion.timeout={{
> iam_biz_tenant_auth_connetion_timeout | default('1000') }}
> iam.biz.tenant.auth.response.timeout={{
> iam_biz_tenant_auth_response_timeout | default('1000') }}
> iam.biz.tenant.auth.retry.count={{ iam_biz_tenant_auth_retry_count |
> default('3') }}
>
> iam.biz.tenant.auth.{{ item.Tenant_ID }}.host= {{ item.Tenant_host }}
> iam.biz.tenant.auth.{{ item.Tenant_ID }}.authType={{ item.Tenant_authType
> }}
> iam.biz.tenant.auth.{{ item.Tenant_ID }}.port={{ item.Tenant_port }}
> iam.biz.tenant.auth.{{ item.Tenant_ID }}.baseDN={{ item.Tenant_baseDN }}
>
> my var file is as follows:
> Tenants:
>   - {"Tenant_ID":"", "Tenant_host":"test1","Tenant_port":"",
> "Tenant_authType":"ldap1234","Tenant_baseDN":"ou=dfhsdjfsd,ou=People,o=
> x.com"}
>   - {"Tenant_ID":"", "Tenant_host":"test7","Tenant_port":"7733",
> "Tenant_authType":"ldap3777","Tenant_baseDN":"ou=,ou=People7,o=
> .com"}
>   - {"Tenant_ID":"4231", "Tenant_host":"test3","Tenant_port":"4433",
> "Tenant_authType":"ldap1","Tenant_baseDN":"ou=dfsd,ou=People21,o=
> xx.com"}
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b5db3d8f-e908-4a32-bd84-259402aa2ee3o%40googlegroups.com
> 
> .
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwN9h3fgd%3DEmY48NaJoiKvuXL0aDaQcyZNi5m4hmwp6p8g%40mail.gmail.com.


Re: [ansible-project] sudo(become) difference between "copy" module and "command" module

2020-06-08 Thread James Cassell


On Mon, Jun 8, 2020, at 11:25 AM, Mukuntha rajaa wrote:
> Hello,
> 
> "become" works perfectly fine with "command" module. But not with 
> "copy" module. Am I doing something wrong here. 
> 
> *_Working playbook:_*
> - name: demo
>  hosts: localhost
>  tasks:
>  - name: copy
>  command: cp /etc/ssh/sshd_config /tmp/sshd_config
>  become: yes
>  - name: edit
>  lineinfile:
>  path: /tmp/sshd_config
>  regexp: '^PermitRootLogin'
>  line: "PermitRootLogin yes"
>  become: yes
> 
> working logs:
>  $ ap lineinfile.yml
> [WARNING]: provided hosts list is empty, only localhost is available. 
> Note that the implicit localhost does not match 'all'
> 
> PLAY [demo] 
> 
> 
> TASK [Gathering Facts] 
> *
> ok: [localhost]
> 
> TASK [copy] 
> 
> changed: [localhost]
> 
> TASK [edit] 
> 
> changed: [localhost]
> 
> PLAY RECAP 
> *
> localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 
> ignored=0
> 
> 
> *_Problematic playbook:_*
> - name: demo
>  hosts: localhost
>  tasks:
>  - name: copy
>  copy:
>  src: /etc/ssh/sshd_config
>  dest: /tmp/sshd_config
>  become: yes
>  - name: edit
>  lineinfile:
>  path: /tmp/sshd_config
>  regexp: '^PermitRootLogin'
>  line: "PermitRootLogin yes"
>  become: yes
> 
> Logs for problematic playbook:
> $ap zz.yml
> [WARNING]: provided hosts list is empty, only localhost is available. 
> Note that the implicit localhost does not match 'all'
> 
> PLAY [demo] 
> 
> 
> TASK [Gathering Facts] 
> *
> ok: [localhost]
> 
> TASK [copy] 
> 
> fatal: [localhost]: FAILED! => {"msg": "an error occurred while trying 
> to read the file '/etc/ssh/sshd_config': [Errno 13] Permission denied: 
> b'/etc/ssh/sshd_config'"}
> 

You want `remote_src: yes`... otherwise it's trying to read the file from the 
controller.

V/r,
James Cassell


> PLAY RECAP 
> *
> localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 
> ignored=0
> 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d437a90c-b2d0-4973-a5f2-701e301d8ac4%40www.fastmail.com.


[ansible-project] While using j2 template and with_items i get the last item in o/p

2020-06-08 Thread Rakesh Parida
Hi 

my playbook is :
   - name: include vars
 include_vars:
   file: /home/rparida1/content-var.yml

   - name: Testing
 template:
   src: /home/rparida1/config.j2
   dest: /home/rparida1/test-raka222.properties
 with_items:
   - "{{ Tenants }}"

When i use the with_items, only the last item mentioned in my var file is 
displayed (my desired o/p is it should iterate through all the items 
mentioned in my var file):

iam.biz.tenant.auth.connetion.timeout=1000
iam.biz.tenant.auth.response.timeout=1000
iam.biz.tenant.auth.retry.count=3

iam.biz.tenant.auth.4231.host= test3
iam.biz.tenant.auth.4231.authType=ldap1
iam.biz.tenant.auth.4231.port=4433
iam.biz.tenant.auth.4231.baseDN=ou=dfsd,ou=People21,o=xx.com 


I have a j2 template as follows:
iam.biz.tenant.auth.connetion.timeout={{ 
iam_biz_tenant_auth_connetion_timeout | default('1000') }}
iam.biz.tenant.auth.response.timeout={{ 
iam_biz_tenant_auth_response_timeout | default('1000') }}
iam.biz.tenant.auth.retry.count={{ iam_biz_tenant_auth_retry_count | 
default('3') }}

iam.biz.tenant.auth.{{ item.Tenant_ID }}.host= {{ item.Tenant_host }}
iam.biz.tenant.auth.{{ item.Tenant_ID }}.authType={{ item.Tenant_authType }}
iam.biz.tenant.auth.{{ item.Tenant_ID }}.port={{ item.Tenant_port }}
iam.biz.tenant.auth.{{ item.Tenant_ID }}.baseDN={{ item.Tenant_baseDN }}

my var file is as follows:
Tenants:
  - {"Tenant_ID":"", "Tenant_host":"test1","Tenant_port":"", 
"Tenant_authType":"ldap1234","Tenant_baseDN":"ou=dfhsdjfsd,ou=People,o=x.com"}
  - {"Tenant_ID":"", "Tenant_host":"test7","Tenant_port":"7733", 
"Tenant_authType":"ldap3777","Tenant_baseDN":"ou=,ou=People7,o=.com"}
  - {"Tenant_ID":"4231", "Tenant_host":"test3","Tenant_port":"4433", 
"Tenant_authType":"ldap1","Tenant_baseDN":"ou=dfsd,ou=People21,o=xx.com"}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b5db3d8f-e908-4a32-bd84-259402aa2ee3o%40googlegroups.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread Dave York
I'm not using a customization template, but it may be possible - I think 
that's what David Foley was referencing.

Check out customization_spec within the vmware_guest module 
https://docs.ansible.com/ansible/latest/modules/vmware_guest_module.html

You can use the method im using OR you can call customization_spec

On Monday, June 8, 2020 at 10:06:57 AM UTC-7, Tony Wong wrote:
>
> Thank you. So for the customization part, i didnt see a mention of the 
> name of the customization template in vcenter. 
>
> so ansible does not use that ?
>
> On Mon, Jun 8, 2020 at 9:46 AM Dave York > 
> wrote:
>
>> These are the two plays I use to do what you were asking about:
>>
>> - name: Ensure Computer Object exists in AD
>> win_domain_computer:
>>   name: '{{ inventory_hostname_short }}'
>>   dns_hostname: '{{ inventory_hostname }}'
>>   domain_server: domaincontroller.fqdn
>>   sam_account_name: '{{ inventory_hostname_short }}$'
>>   ou: '{{ AD_OU }}'
>>   description: '{{ owner_email }}'
>>   enabled: yes
>>   state: present
>> delegate_to: utilityserver.fqdn
>>
>>   - name: Clone to VM from Template
>> vmware_guest:
>>   hostname: '{{ vsphere_hostname }}' 
>>   username: '{{ lookup("env", "VMWARE_USER") }}'
>>   password: '{{ lookup("env", "VMWARE_PASSWORD") }}'
>>   validate_certs: no
>>   folder: '{{ vmware_folder }}'
>>   annotation: "{{ owner_email }}"
>>   datacenter: '{{ vmware_datacenter }}'
>>   name: '{{ inventory_hostname_short }}'
>>   cluster: '{{ vmware_cluster }}'
>>   state: poweredon
>>   template: '{{ vmware_template }}'
>>   datastore: '{{ vmware_datastore }}'
>>   customization:
>> domainadmin: '{{ lookup("env", "ANSIBLE_NET_USERNAME") }}'
>> domainadminpassword: 
>> '{{ lookup("env", "ANSIBLE_NET_PASSWORD") }}'
>> joindomain: domain.fqdn
>> password: '{{ templatepwd }}'
>> timezone: 004
>>   disk:
>>   - size_gb: 100
>> type: thin
>>   - size_gb: 100
>> type: thin
>>   hardware:
>> memory_mb: '{{ vmware_mem }}'
>> num_cpus: '{{ vmware_cpu }}'
>> scsi: paravirtual
>> hotadd_cpu: True
>> hotremove_cpu: True
>> hotadd_memory: True
>> boot_firmware: "efi"
>>   networks:
>>   - name: '{{ vmware_network }}'
>> ip: '{{ ipv4 }}'
>> netmask: '255.255.255.0'
>> gateway: '{{ ipv4_gateway }}'
>> device_type: vmxnet3
>> dns_servers: 
>> - '{{ dns_primary }}'
>> - '{{ dns_secondary }}'
>>   wait_for_ip_address: yes
>>   wait_for_customization: yes
>> delegate_to: localhost
>> register: deploy
>>
>>
>> On Monday, June 8, 2020 at 7:15:11 AM UTC-7, Tony Wong wrote:
>>>
>>> for ansible, is there a reverse order to detroy the vms after the vm 
>>> playbook has been run like terraform? Or do I need to create another 
>>> playbook to destroy the vms?
>>>
>>> On Mon, Jun 8, 2020 at 6:59 AM Tony Wong  wrote:
>>>
 I got a customization template in vcenter. how do I specify using that 
 template. Also the template looks like will override my static IP settings 
 on my Vms. 

 On Sun, Jun 7, 2020 at 3:31 PM Dave York  wrote:

> Ive done this by using the customization argument of the vmware_guest 
> module to join the domain. but prior to vmware_guest i use a 
> win_domain_computer delegated to a windows utility box to prestage the 
> computer object in the right ou 
>
> Sent from Outlook Mobile 
>
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/BY5PR11MB389625F705684B8C33E6891EA1840%40BY5PR11MB3896.namprd11.prod.outlook.com
>  
> 
> .
>
 -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/a6389e24-f428-4922-b2a2-e5dc8489cbc6o%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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] Windows Domain/Ansible Kerberos Auth Issues Still

2020-06-08 Thread Dave York
(I've posted a bit about this before, but I want to revisit it because its 
frustrating as I try to optimize my playbooks)

I have a playbook where I build servers from vmware templates using 
vmware_guest and I join the domain using that module.  Once the servers are 
built I have an extremely long "wait_for_connection":

  - name: Wait until server becomes available to connect
wait_for_connection:
  delay: 900 #Wait 10 minutes before trying
  sleep: 30 #After 10 minutes, try every 30 seconds
  timeout: 1200 #Maximum amount of time to wait

After this wait, I start running tasks on the new hosts.  Initially, those 
tasks will run fine, but one-by-one, randomly, the servers will start 
failing with Kerberos errors.  During this time I can confirm im able to 
login to these servers using the same credentials, so the authentication 
doesn't seem to be failing outside of ansible, but it fails within ansible 
for some reason.

The longer I wait after building the servers, the less likely this issue 
occurs.  It just seems insane that I have to keep adding more wait time.  

Here's me running the playbook against 4 servers.  Each task runs against 
all four servers but the red lines highlighed show the kerberos failures 
and the eventual atrophy of the playbook entirely because of the kerberos 
errors:

TASK [Registry fix to enable solution for CVE-2017-8529 Part 1] 

Monday 08 June 2020  16:32:22 + (0:00:09.368)   0:33:29.081 
*** 
changed: [server4.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
changed: [server1.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
changed: [server3.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
changed: [server2.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
TASK [Registry fix to enable solution for CVE-2017-8529 Part 2] 

Monday 08 June 2020  16:32:25 + (0:00:03.635)   0:33:32.717 
*** 
changed: [server1.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
changed: [server4.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
changed: [server2.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
changed: [server3.fqdn] => {"changed": true, "data_changed": false, 
"data_type_changed": false}
TASK Configure UAC] 
*
Monday 08 June 2020  16:32:29 + (0:00:03.388)   0:33:36.105 
*** 
fatal: [server3.fqdn]: UNREACHABLE! => {"changed": false, "msg": "kerberos: 
the specified credentials were rejected by the server", "unreachable": true}
changed: [server1.fqdn] => {"changed": true, "data_changed": true, 
"data_type_changed": false}
changed: [server2.fqdn] => {"changed": true, "data_changed": true, 
"data_type_changed": false}
changed: [server4.fqdn] => {"changed": true, "data_changed": true, 
"data_type_changed": false}
TASK [Initialize Disk 1] 
***
Monday 08 June 2020  16:32:32 + (0:00:03.335)   0:33:39.440 
*** 
changed: [server4.fqdn] => {"changed": true, "cmd": "Initialize-Disk 
-Number 1", "delta": "0:00:04.105311", "end": "2020-06-08 04:32:39.137372", 
"rc": 0, "start": "2020-06-08 04:32:35.032060", "stderr": "", 
"stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [server1.fqdn] => {"changed": true, "cmd": "Initialize-Disk 
-Number 1", "delta": "0:00:03.903042", "end": "2020-06-08 04:32:39.527549", 
"rc": 0, "start": "2020-06-08 04:32:35.624506", "stderr": "", 
"stderr_lines": [], "stdout": "", "stdout_lines": []}
changed: [server2.fqdn] => {"changed": true, "cmd": "Initialize-Disk 
-Number 1", "delta": "0:00:05.007749", "end": "2020-06-08 04:32:40.903429", 
"rc": 0, "start": "2020-06-08 04:32:35.895680", "stderr": "", 
"stderr_lines": [], "stdout": "", "stdout_lines": []}
TASK [Wait 15 seconds for disk initilization] 
**
Monday 08 June 2020  16:32:41 + (0:00:08.457)   0:33:47.898 
*** 
Pausing for 15 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
ok: [server1.fqdn] => {"changed": false, "delta": 15, "echo": true, "rc": 
0, "start": "2020-06-08 16:32:41.126472", "stderr": "", "stdout": "Paused 
for 15.0 seconds", "stop": "2020-06-08 16:32:56.126843", "user_input": ""}
TASK [Partition Disk 1] 

Monday 08 June 2020  16:32:56 + (0:00:15.051)   0:34:02.949 
*** 
changed: [server4.fqdn] => {"changed": true}
changed: [server1.fqdn] => {"changed": true}
changed: [server2.fqdn] => {"changed": true}
TASK [Format Disk 1 as E drive] 

Monday 08 June 2020  16:33:03 + (0:00:06.888)   0:34:09.838 
*** 
changed: [server4.fqdn] => {"changed": true}
changed: 

Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread Tony Wong
Thank you. So for the customization part, i didnt see a mention of the name
of the customization template in vcenter.

so ansible does not use that ?

On Mon, Jun 8, 2020 at 9:46 AM Dave York  wrote:

> These are the two plays I use to do what you were asking about:
>
> - name: Ensure Computer Object exists in AD
> win_domain_computer:
>   name: '{{ inventory_hostname_short }}'
>   dns_hostname: '{{ inventory_hostname }}'
>   domain_server: domaincontroller.fqdn
>   sam_account_name: '{{ inventory_hostname_short }}$'
>   ou: '{{ AD_OU }}'
>   description: '{{ owner_email }}'
>   enabled: yes
>   state: present
> delegate_to: utilityserver.fqdn
>
>   - name: Clone to VM from Template
> vmware_guest:
>   hostname: '{{ vsphere_hostname }}'
>   username: '{{ lookup("env", "VMWARE_USER") }}'
>   password: '{{ lookup("env", "VMWARE_PASSWORD") }}'
>   validate_certs: no
>   folder: '{{ vmware_folder }}'
>   annotation: "{{ owner_email }}"
>   datacenter: '{{ vmware_datacenter }}'
>   name: '{{ inventory_hostname_short }}'
>   cluster: '{{ vmware_cluster }}'
>   state: poweredon
>   template: '{{ vmware_template }}'
>   datastore: '{{ vmware_datastore }}'
>   customization:
> domainadmin: '{{ lookup("env", "ANSIBLE_NET_USERNAME") }}'
> domainadminpassword: '{{ lookup("env", "ANSIBLE_NET_PASSWORD") }}'
> joindomain: domain.fqdn
> password: '{{ templatepwd }}'
> timezone: 004
>   disk:
>   - size_gb: 100
> type: thin
>   - size_gb: 100
> type: thin
>   hardware:
> memory_mb: '{{ vmware_mem }}'
> num_cpus: '{{ vmware_cpu }}'
> scsi: paravirtual
> hotadd_cpu: True
> hotremove_cpu: True
> hotadd_memory: True
> boot_firmware: "efi"
>   networks:
>   - name: '{{ vmware_network }}'
> ip: '{{ ipv4 }}'
> netmask: '255.255.255.0'
> gateway: '{{ ipv4_gateway }}'
> device_type: vmxnet3
> dns_servers:
> - '{{ dns_primary }}'
> - '{{ dns_secondary }}'
>   wait_for_ip_address: yes
>   wait_for_customization: yes
> delegate_to: localhost
> register: deploy
>
>
> On Monday, June 8, 2020 at 7:15:11 AM UTC-7, Tony Wong wrote:
>>
>> for ansible, is there a reverse order to detroy the vms after the vm
>> playbook has been run like terraform? Or do I need to create another
>> playbook to destroy the vms?
>>
>> On Mon, Jun 8, 2020 at 6:59 AM Tony Wong  wrote:
>>
>>> I got a customization template in vcenter. how do I specify using that
>>> template. Also the template looks like will override my static IP settings
>>> on my Vms.
>>>
>>> On Sun, Jun 7, 2020 at 3:31 PM Dave York  wrote:
>>>
 Ive done this by using the customization argument of the vmware_guest
 module to join the domain. but prior to vmware_guest i use a
 win_domain_computer delegated to a windows utility box to prestage the
 computer object in the right ou

 Sent from Outlook Mobile 

 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/ansible-project/BY5PR11MB389625F705684B8C33E6891EA1840%40BY5PR11MB3896.namprd11.prod.outlook.com
 
 .

>>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a6389e24-f428-4922-b2a2-e5dc8489cbc6o%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALmkhkqghOjSVNO8wMSUzZR7M%2B-6rtNX2TwSgBgnBntq6rzSow%40mail.gmail.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread Dave York
These are the two plays I use to do what you were asking about:

- name: Ensure Computer Object exists in AD
win_domain_computer:
  name: '{{ inventory_hostname_short }}'
  dns_hostname: '{{ inventory_hostname }}'
  domain_server: domaincontroller.fqdn
  sam_account_name: '{{ inventory_hostname_short }}$'
  ou: '{{ AD_OU }}'
  description: '{{ owner_email }}'
  enabled: yes
  state: present
delegate_to: utilityserver.fqdn

  - name: Clone to VM from Template
vmware_guest:
  hostname: '{{ vsphere_hostname }}' 
  username: '{{ lookup("env", "VMWARE_USER") }}'
  password: '{{ lookup("env", "VMWARE_PASSWORD") }}'
  validate_certs: no
  folder: '{{ vmware_folder }}'
  annotation: "{{ owner_email }}"
  datacenter: '{{ vmware_datacenter }}'
  name: '{{ inventory_hostname_short }}'
  cluster: '{{ vmware_cluster }}'
  state: poweredon
  template: '{{ vmware_template }}'
  datastore: '{{ vmware_datastore }}'
  customization:
domainadmin: '{{ lookup("env", "ANSIBLE_NET_USERNAME") }}'
domainadminpassword: '{{ lookup("env", "ANSIBLE_NET_PASSWORD") }}'
joindomain: domain.fqdn
password: '{{ templatepwd }}'
timezone: 004
  disk:
  - size_gb: 100
type: thin
  - size_gb: 100
type: thin
  hardware:
memory_mb: '{{ vmware_mem }}'
num_cpus: '{{ vmware_cpu }}'
scsi: paravirtual
hotadd_cpu: True
hotremove_cpu: True
hotadd_memory: True
boot_firmware: "efi"
  networks:
  - name: '{{ vmware_network }}'
ip: '{{ ipv4 }}'
netmask: '255.255.255.0'
gateway: '{{ ipv4_gateway }}'
device_type: vmxnet3
dns_servers: 
- '{{ dns_primary }}'
- '{{ dns_secondary }}'
  wait_for_ip_address: yes
  wait_for_customization: yes
delegate_to: localhost
register: deploy


On Monday, June 8, 2020 at 7:15:11 AM UTC-7, Tony Wong wrote:
>
> for ansible, is there a reverse order to detroy the vms after the vm 
> playbook has been run like terraform? Or do I need to create another 
> playbook to destroy the vms?
>
> On Mon, Jun 8, 2020 at 6:59 AM Tony Wong > 
> wrote:
>
>> I got a customization template in vcenter. how do I specify using that 
>> template. Also the template looks like will override my static IP settings 
>> on my Vms. 
>>
>> On Sun, Jun 7, 2020 at 3:31 PM Dave York > 
>> wrote:
>>
>>> Ive done this by using the customization argument of the vmware_guest 
>>> module to join the domain. but prior to vmware_guest i use a 
>>> win_domain_computer delegated to a windows utility box to prestage the 
>>> computer object in the right ou 
>>>
>>> Sent from Outlook Mobile 
>>>
>>> -- 
>>> 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...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/BY5PR11MB389625F705684B8C33E6891EA1840%40BY5PR11MB3896.namprd11.prod.outlook.com
>>>  
>>> 
>>> .
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a6389e24-f428-4922-b2a2-e5dc8489cbc6o%40googlegroups.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread Dave York
These are the two plays I use to do what you're talking about:

- name: Ensure Computer Object exists in AD
win_domain_computer:
  name: '{{ inventory_hostname_short }}'
  dns_hostname: '{{ inventory_hostname }}'
  domain_server: DC you want to run the prestage computer object on 
  sam_account_name: '{{ inventory_hostname_short }}$'
  ou: '{{ AD_OU }}'
  description: '{{ environment_owner_email }}'
  enabled: yes
  state: present
delegate_to: WINDOWS UTILITY SERVER FQDN

  - name: Clone to VM from Template
vmware_guest:
  hostname: '{{ vsphere_hostname }}' 
  username: '{{ lookup("env", "VMWARE_USER") }}'
  password: '{{ lookup("env", "VMWARE_PASSWORD") }}'
  validate_certs: no
  folder: '{{ vmware_folder }}'
  annotation: "{{ apollo_environment_owner_email }}"
  datacenter: '{{ vmware_datacenter }}'
  name: '{{ inventory_hostname_short }}'
  cluster: '{{ vmware_cluster }}'
  state: poweredon
  template: '{{ vmware_template }}'
  datastore: '{{ vmware_datastore }}'
  customization:
domainadmin: '{{ lookup("env", "ANSIBLE_NET_USERNAME") }}'
domainadminpassword: '{{ lookup("env", "ANSIBLE_NET_PASSWORD") }}'
joindomain: internal.mcmcg.com
password: '{{ templatepwd }}'
timezone: 004
  disk:
  - size_gb: 100
type: thin
  - size_gb: 100
type: thin
  hardware:
memory_mb: '{{ vmware_mem }}'
num_cpus: '{{ vmware_cpu }}'
scsi: paravirtual
hotadd_cpu: True
hotremove_cpu: True
hotadd_memory: True
boot_firmware: "efi"
  networks:
  - name: '{{ vmware_network }}'
ip: '{{ ipv4 }}'
netmask: '255.255.255.0'
gateway: '{{ ipv4_gateway }}'
device_type: vmxnet3
dns_servers: 
- '{{ dns_primary }}'
- '{{ dns_secondary }}'
  wait_for_ip_address: yes
  wait_for_customization: yes
delegate_to: localhost
register: deploy


On Monday, June 8, 2020 at 7:15:11 AM UTC-7, Tony Wong wrote:
>
> for ansible, is there a reverse order to detroy the vms after the vm 
> playbook has been run like terraform? Or do I need to create another 
> playbook to destroy the vms?
>
> On Mon, Jun 8, 2020 at 6:59 AM Tony Wong > 
> wrote:
>
>> I got a customization template in vcenter. how do I specify using that 
>> template. Also the template looks like will override my static IP settings 
>> on my Vms. 
>>
>> On Sun, Jun 7, 2020 at 3:31 PM Dave York > 
>> wrote:
>>
>>> Ive done this by using the customization argument of the vmware_guest 
>>> module to join the domain. but prior to vmware_guest i use a 
>>> win_domain_computer delegated to a windows utility box to prestage the 
>>> computer object in the right ou 
>>>
>>> Sent from Outlook Mobile 
>>>
>>> -- 
>>> 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...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/BY5PR11MB389625F705684B8C33E6891EA1840%40BY5PR11MB3896.namprd11.prod.outlook.com
>>>  
>>> 
>>> .
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cf631a6f-1064-4869-a34d-b0e8ab54a67bo%40googlegroups.com.


[ansible-project] ansible-playbook and different screen / file log output

2020-06-08 Thread Waldek Maleska
Hello,

I was wondering if such a logging scenario is possible out of the box with 
Ansible or it it something which would need to be implemented as a custom 
callback plugin:

   - on screen (stdout), I'd like to see all changed/failed/warning tasks 
   but not the ok/skipped tasks
  - if it was just this, I'd use parameters from 
  https://docs.ansible.com/ansible/latest/plugins/callback/default.html, 
  namely env:ANSIBLE_DISPLAY_OK_HOSTS and env:ANSIBLE_DISPLAY_SKIPPED_HOSTS
   - in a log file (ideally in structure such as by *tree plugin *but even 
   a single output file ANSIBLE_LOG_PATH 
   

 would 
   be ok) I'd like to log *all* the tasks, no matter their status

I was trying several combinations of settings but wasn't lucky; whenever 
the console output was shortened, so was the information in the log file.

Any suggestions?

Thanks,
Waldek

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3ebacfc4-c568-42dc-9df8-56ec72ebe1a5o%40googlegroups.com.


Re: [ansible-project] aws community edition and collection

2020-06-08 Thread Matt Martz
That is controlled by lib/ansible/config/ansible_builtin_runtime.yml

It is designed to only allow modules which shipped with Ansible previously,
to work without needing to use the FQCN for backwards compatibility.

On Mon, Jun 8, 2020 at 10:21 AM Sydo Luciani  wrote:

> Thank you Matt, adding FQDN of the module fixed the problem either in
> playbook or ansible-doc command line.
>
> How is that existing modules can be found just with their name but not the
> new one ?
> There is action_groups.yml in meta directory, but adding testing_module
> to it didn't make any difference.
>
> On Mon, 8 Jun 2020 at 10:00, Matt Martz  wrote:
>
>> You have to use the FQCN of the module, at least for ansible-doc:
>>  community.aws.testing_module
>>
>> On Mon, Jun 8, 2020 at 9:58 AM Sydo Luciani 
>> wrote:
>>
>>> Created a new module in
>>> "~/ansible_dev/ansible_collections/community/aws/plugins/modules", but
>>> neither ansible-playbook nor ansible-doc finds the new module. for the sake
>>> of test, copied a module to new name, to make sure it is not related to
>>> module content, and original module can be found, but not the new one.
>>>
>>> ansible-doc -t module testing_module
>>>
>>> Checking collections development document:
>>>
>>> https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html
>>>
>>> but can't find any thing about adding a new module.
>>>
>>> What am I missing ?
>>>
>>> Thanks
>>>
>>>
>>> On Thu, 4 Jun 2020 at 22:10, Jordan Borean  wrote:
>>>
 You've identified one of the many annoying parts of collections. You
> need a special directory structure and you can't install from git in an
> editable manner.


 Admittedly you are right about the special directory structure but it's
 pretty trivial to install it from git in an editable manner. I do this for
 the Windows collections;

 # Usually I have this in my ~/.bashrc where the last segment is my dev
 location
 export ANSIBLE_COLLECTIONS_PATHS=~/.ansible/collections:/usr/share/
 ansible/collections:~/ansible-dev
 git clone g...@github.com:ansible-collections/ansible.windows.git ~
 /ansible-dev/ansible_collections/ansible/windows

 I won't lie and say this is a perfect scenario but it's just 2
 commands, one of which can be set automatically in your profile.

 --
 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/ansible-project/c3c6a188-ff2c-4d5c-be96-774ce225023fo%40googlegroups.com
 
 .

>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAJspodimWwD2Tgo4Go5dPXVepjnTiEuU7T3ooO8LRAwU2Vm6Eg%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAD8N0v_-rEDhjHZkK40VZk3XQ0eZEaB__L%3DARkqag%3DAe7dd7jg%40mail.gmail.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJspodghPuEcjBTjN-o%2BSD3ZU-bigDJwEG85FNnv8-tw8MfUBw%40mail.gmail.com
> 
> .
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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 view this discussion on 

[ansible-project] sudo(become) difference between "copy" module and "command" module

2020-06-08 Thread Mukuntha rajaa
Hello,

"become" works perfectly fine with "command" module. But not with "copy" 
module. Am I doing something wrong here. 

*Working playbook:*
- name: demo
  hosts: localhost
  tasks:
- name: copy
  command: cp /etc/ssh/sshd_config /tmp/sshd_config
  become: yes
- name: edit
  lineinfile:
path: /tmp/sshd_config
regexp: '^PermitRootLogin'
line: "PermitRootLogin yes"
  become: yes

working logs:
 $ ap lineinfile.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'

PLAY [demo] 


TASK [Gathering Facts] 
*
ok: [localhost]

TASK [copy] 

changed: [localhost]

TASK [edit] 

changed: [localhost]

PLAY RECAP 
*
localhost  : ok=3changed=2unreachable=0
failed=0skipped=0rescued=0ignored=0


*Problematic playbook:*
- name: demo
  hosts: localhost
  tasks:
- name: copy
  copy:
src: /etc/ssh/sshd_config
dest: /tmp/sshd_config
  become: yes
- name: edit
  lineinfile:
path: /tmp/sshd_config
regexp: '^PermitRootLogin'
line: "PermitRootLogin yes"
  become: yes

Logs for problematic playbook:
$ap zz.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'

PLAY [demo] 


TASK [Gathering Facts] 
*
ok: [localhost]

TASK [copy] 

fatal: [localhost]: FAILED! => {"msg": "an error occurred while trying to 
read the file '/etc/ssh/sshd_config': [Errno 13] Permission denied: 
b'/etc/ssh/sshd_config'"}

PLAY RECAP 
*
localhost  : ok=1changed=0unreachable=0
failed=1skipped=0rescued=0ignored=0


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/57967572-52d9-4b68-a05a-0f10be1e5d37o%40googlegroups.com.


[ansible-project] how to read variable from j2 and insert multiple values in final file

2020-06-08 Thread Aditya
Hi Guys,

I have to write a task to read a j2 file and values from inventory and 
update the final file with multiple values of same variable defined in j2. 
I have tried to explain it with an example below.  

Please note i cannot create multiple variables in j2 file as i want this to 
be handled through ansible/inventory. 

Also i cannot define the values in my task as no. of variables will differ 
for different environments. For example site1 will have 1 tenantID and 
site2 might have 3.

test.j2 

timeout.config=1000
retry.count=3

#Multiple values
{{Tenant_ID}}.host={{ Tenant_ID_host }}


Inventory file
Tenants:
- {"Tenant_ID":"1234","Tenant_ID_host":"test"}
- {"Tenant_ID":"5657","Tenant_ID_host":"test1"}

Final test file should look like 
   
timeout.config=1000
retry.count=3

1234.host=test
5657.host=test1

Thank you!!
Aditya

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3f4f96c8-c631-4428-a981-92976d18bb7eo%40googlegroups.com.


Re: [ansible-project] aws community edition and collection

2020-06-08 Thread Sydo Luciani
Thank you Matt, adding FQDN of the module fixed the problem either in
playbook or ansible-doc command line.

How is that existing modules can be found just with their name but not the
new one ?
There is action_groups.yml in meta directory, but adding testing_module to
it didn't make any difference.

On Mon, 8 Jun 2020 at 10:00, Matt Martz  wrote:

> You have to use the FQCN of the module, at least for ansible-doc:
>  community.aws.testing_module
>
> On Mon, Jun 8, 2020 at 9:58 AM Sydo Luciani 
> wrote:
>
>> Created a new module in
>> "~/ansible_dev/ansible_collections/community/aws/plugins/modules", but
>> neither ansible-playbook nor ansible-doc finds the new module. for the sake
>> of test, copied a module to new name, to make sure it is not related to
>> module content, and original module can be found, but not the new one.
>>
>> ansible-doc -t module testing_module
>>
>> Checking collections development document:
>>
>> https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html
>>
>> but can't find any thing about adding a new module.
>>
>> What am I missing ?
>>
>> Thanks
>>
>>
>> On Thu, 4 Jun 2020 at 22:10, Jordan Borean  wrote:
>>
>>> You've identified one of the many annoying parts of collections. You
 need a special directory structure and you can't install from git in an
 editable manner.
>>>
>>>
>>> Admittedly you are right about the special directory structure but it's
>>> pretty trivial to install it from git in an editable manner. I do this for
>>> the Windows collections;
>>>
>>> # Usually I have this in my ~/.bashrc where the last segment is my dev
>>> location
>>> export ANSIBLE_COLLECTIONS_PATHS=~/.ansible/collections:/usr/share/
>>> ansible/collections:~/ansible-dev
>>> git clone g...@github.com:ansible-collections/ansible.windows.git ~
>>> /ansible-dev/ansible_collections/ansible/windows
>>>
>>> I won't lie and say this is a perfect scenario but it's just 2 commands,
>>> one of which can be set automatically in your profile.
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/c3c6a188-ff2c-4d5c-be96-774ce225023fo%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAJspodimWwD2Tgo4Go5dPXVepjnTiEuU7T3ooO8LRAwU2Vm6Eg%40mail.gmail.com
>> 
>> .
>>
>
>
> --
> Matt Martz
> @sivel
> sivel.net
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAD8N0v_-rEDhjHZkK40VZk3XQ0eZEaB__L%3DARkqag%3DAe7dd7jg%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJspodghPuEcjBTjN-o%2BSD3ZU-bigDJwEG85FNnv8-tw8MfUBw%40mail.gmail.com.


Re: [ansible-project] aws community edition and collection

2020-06-08 Thread Matt Martz
You have to use the FQCN of the module, at least for ansible-doc:
 community.aws.testing_module

On Mon, Jun 8, 2020 at 9:58 AM Sydo Luciani  wrote:

> Created a new module in
> "~/ansible_dev/ansible_collections/community/aws/plugins/modules", but
> neither ansible-playbook nor ansible-doc finds the new module. for the sake
> of test, copied a module to new name, to make sure it is not related to
> module content, and original module can be found, but not the new one.
>
> ansible-doc -t module testing_module
>
> Checking collections development document:
>
> https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html
>
> but can't find any thing about adding a new module.
>
> What am I missing ?
>
> Thanks
>
>
> On Thu, 4 Jun 2020 at 22:10, Jordan Borean  wrote:
>
>> You've identified one of the many annoying parts of collections. You need
>>> a special directory structure and you can't install from git in an editable
>>> manner.
>>
>>
>> Admittedly you are right about the special directory structure but it's
>> pretty trivial to install it from git in an editable manner. I do this for
>> the Windows collections;
>>
>> # Usually I have this in my ~/.bashrc where the last segment is my dev
>> location
>> export ANSIBLE_COLLECTIONS_PATHS=~/.ansible/collections:/usr/share/
>> ansible/collections:~/ansible-dev
>> git clone g...@github.com:ansible-collections/ansible.windows.git ~
>> /ansible-dev/ansible_collections/ansible/windows
>>
>> I won't lie and say this is a perfect scenario but it's just 2 commands,
>> one of which can be set automatically in your profile.
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/c3c6a188-ff2c-4d5c-be96-774ce225023fo%40googlegroups.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJspodimWwD2Tgo4Go5dPXVepjnTiEuU7T3ooO8LRAwU2Vm6Eg%40mail.gmail.com
> 
> .
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_-rEDhjHZkK40VZk3XQ0eZEaB__L%3DARkqag%3DAe7dd7jg%40mail.gmail.com.


Re: [ansible-project] aws community edition and collection

2020-06-08 Thread Sydo Luciani
Created a new module in
"~/ansible_dev/ansible_collections/community/aws/plugins/modules", but
neither ansible-playbook nor ansible-doc finds the new module. for the sake
of test, copied a module to new name, to make sure it is not related to
module content, and original module can be found, but not the new one.

ansible-doc -t module testing_module

Checking collections development document:
https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html

but can't find any thing about adding a new module.

What am I missing ?

Thanks


On Thu, 4 Jun 2020 at 22:10, Jordan Borean  wrote:

> You've identified one of the many annoying parts of collections. You need
>> a special directory structure and you can't install from git in an editable
>> manner.
>
>
> Admittedly you are right about the special directory structure but it's
> pretty trivial to install it from git in an editable manner. I do this for
> the Windows collections;
>
> # Usually I have this in my ~/.bashrc where the last segment is my dev
> location
> export ANSIBLE_COLLECTIONS_PATHS=~/.ansible/collections:/usr/share/ansible
> /collections:~/ansible-dev
> git clone g...@github.com:ansible-collections/ansible.windows.git ~
> /ansible-dev/ansible_collections/ansible/windows
>
> I won't lie and say this is a perfect scenario but it's just 2 commands,
> one of which can be set automatically in your profile.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c3c6a188-ff2c-4d5c-be96-774ce225023fo%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJspodimWwD2Tgo4Go5dPXVepjnTiEuU7T3ooO8LRAwU2Vm6Eg%40mail.gmail.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread David Foley
So you want to do something like Terraform init / plan & Apply and once 
finished you want to do a Terraform Destroy? 

No Ansible doesn't do State Files 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9b905e14-20a3-4f69-a5cc-c0a8a547ac3bo%40googlegroups.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread David Foley

>
> I'll assume you are refering to Custom Specs within vCenter :
>
>
You can use the following: 
https://docs.ansible.com/ansible/latest/modules/vmware_guest_module.html

*customization_spec*  

-
added in 2.6
Unique name identifying the requested customization specification.
This parameter is case sensitive.
If set, then overrides customization parameter values.
 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ad930091-eb03-4962-ae53-494beafd0f8ao%40googlegroups.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread Tony Wong
for ansible, is there a reverse order to detroy the vms after the vm
playbook has been run like terraform? Or do I need to create another
playbook to destroy the vms?

On Mon, Jun 8, 2020 at 6:59 AM Tony Wong  wrote:

> I got a customization template in vcenter. how do I specify using that
> template. Also the template looks like will override my static IP settings
> on my Vms.
>
> On Sun, Jun 7, 2020 at 3:31 PM Dave York  wrote:
>
>> Ive done this by using the customization argument of the vmware_guest
>> module to join the domain. but prior to vmware_guest i use a
>> win_domain_computer delegated to a windows utility box to prestage the
>> computer object in the right ou
>>
>> Sent from Outlook Mobile 
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/BY5PR11MB389625F705684B8C33E6891EA1840%40BY5PR11MB3896.namprd11.prod.outlook.com
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALmkhkrba%3Da6pNfvBVQMQWACTtbCqaVWnqKZHSqyAC1w2jACsQ%40mail.gmail.com.


Re: [ansible-project] deploy VM from template and customize guest

2020-06-08 Thread Tony Wong
I got a customization template in vcenter. how do I specify using that
template. Also the template looks like will override my static IP settings
on my Vms.

On Sun, Jun 7, 2020 at 3:31 PM Dave York  wrote:

> Ive done this by using the customization argument of the vmware_guest
> module to join the domain. but prior to vmware_guest i use a
> win_domain_computer delegated to a windows utility box to prestage the
> computer object in the right ou
>
> Sent from Outlook Mobile 
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/BY5PR11MB389625F705684B8C33E6891EA1840%40BY5PR11MB3896.namprd11.prod.outlook.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALmkhkqDMvNjkTcExLf86h6s6eW3-isTtMYDU0DLRSH500k_Ng%40mail.gmail.com.


[ansible-project] win_mapped_drive dont work with User in Admin group

2020-06-08 Thread Pedro Cruz
Hi,

I am trying to use the module win_mapped_drive on Windows Server 2016 and 
in a user other than Admin the credentials are not saved after the restart. 
These are my playbooks:

playbook1.yml:

---
- hosts: windows
  tasks:
  - name: Create a mapped drive that requires authentication
win_mapped_drive:
  letter: U
  path: \\labnasstor01.qs.de\virtual11
  state: present
  username: labnasstor01.qs.de\qskills
  password: qskills123

playbook2.yml:

---
- hosts: windows
#  become: yes
#  become_method: runas
#  become_user: SYSTEM
  tasks:

  - name: Save the network credentials required for the mapped drive
win_credential:
  name: labnasstor01.qs.de
  type: domain_password
  username: labnasstor01.qs.de\qskills
  secret: qskills123
  state: present

#  - name: sign out after mapping
#win_command: shutdown /L /f

#  - name: reboot after mapping
#win_shell: Restart-Computer -Force

inventory:

[windows]
10.75.15.2

[windows:vars]
ansible_user=student
ansible_password=qskills123
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore


I have tried using "become" but without success. Maybe someone has some 
idea :)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6a1409fd-4a59-40c5-9a67-6a7660a480f4o%40googlegroups.com.