[ansible-project] Re: gcp_compute_instance module not attaching persistent disk to VM

2020-04-08 Thread Dimitar Savov
Hello Rafael,

Just to let you know I have opened a bug report about this.

https://github.com/ansible/ansible/issues/68766

Best regards,

-- 
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/32648f76-27ba-4ba4-831c-3fc4fc6a0a06%40googlegroups.com.


[ansible-project] Re: gcp_compute_instance module not attaching persistent disk to VM

2020-04-08 Thread Dimitar Savov
Hello Rafael,

Just to let you know I have opened a bug report about this.

https://github.com/ansible/ansible/issues/68766

Best regards,
Dimitar

On Thursday, August 1, 2019 at 3:04:50 AM UTC+3, Rafael Soutelino wrote:
>
> Hi All, 
>
> I’m working on a playbook that creates a new persistent disk in google 
> cloud, attaches to an existing VM, formats, mounts and sets it up. 
> Everything seems to be working fine except the step where the disk gets 
> attached, it seems ansible is ignoring that VM state change. 
>
> I tried to simply call the existing VM again with the new disk, which 
> didn’t work. Then I thought it could be a problem with the fact that the 
> other existing disks were not declared. So I wrote some tasks to gather the 
> disks, create dictionaries that capture the disk properties as they are 
> required by the “disks” parameter of the gcp_compute_instance module, which 
> is how the below playbook is currently set up. But that didn’t work either. 
>
> I’ve also tried to create tasks before and after the attempt to attach the 
> disk by setting the VM status to TERMINATED and RUNNING, to rule out the 
> possibility of google cloud not accepting attachments with the machine 
> running (although this is OK doing in the console). 
>
> Anything I might be missing here?
>
> I noticed the azure_rm_managed_disk has a parameter called managed_by. 
> Maybe the GCP modules are yet to implement such functionality?
>
> Playbook: scratch.yml
>
> ---
> - name: Add a scratch disk to an existing VM
>   hosts: localhost
>   gather_facts: no
>   connection: local
>
>   vars_files: 
> - vars/gcp_vm
>
>   tasks:
>   - name: Provision scratch and attach to VM
> when: destroy == "no"
>
> block:
>   - name: Getting facts from VM
> gcp_compute_instance_facts:
>   zone: "{{ zone }}"
>   filters:
>   - name = {{ instance_name }}
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
> register: vm
>
>   - name: Gathering VMs existing disks
> set_fact:
>   disks: "{{ vm['items'][0]['disks'] }}"
>
>   - name: Create scratch disk
> gcp_compute_disk:
>   name: "{{ scratch_disk_name }}"
>   type: "{{ scratch_disk_type }}"
>   zone: "{{ zone }}"
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
>   state: present
> register: scratch
>
>   - name: Convert new disk to format expected by 
> gcp_compute_instance_facts
> vars: 
>   newdisk: []
> set_fact:
>   newdisk: "{{ newdisk + [ {'auto_delete': false, 'boot': false, 
> 'source': item[1]} ] }}"
> with_indexed_items: "{{ [ scratch ] }}"
>
>   - name: Create list of currently attached disks
> vars:
>   alldisks: []
> set_fact:
>   alldisks: "{{ alldisks + [ {'auto_delete': item['autoDelete'], 
> 'boot': item['boot'], 'source': item} ] }}"
> with_items: "{{ disks }}"
>
>   - name: Append new disk
> set_fact:
>   alldisks: "{{ alldisks + [ newdisk[0] ] }}"
>
>   - name: Attach disk to VM
> gcp_compute_instance:
>   state: present
>   name: "{{ instance_name }}"
>   disks: "{{ alldisks }}"
>   zone: "{{ zone }}"
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
>
>   - name: Get IP address from instance
> gcp_compute_address:
>   name: "{{ instance_name }}"
>   region: "{{ region }}"
>   project: "{{ gcp_project }}"
>   auth_kind: "{{ gcp_cred_kind }}"
>   service_account_file: "{{ gcp_cred_file }}"
>   state: present
> register: address
>
>   - name: Wait for SSH to come up
> wait_for: host={{ address.address }} port=22 delay=10 timeout=60
>
>   - name: Add host to groupname
> add_host: hostname={{ address.address }} groupname=vm
>
>
> - name: Format and mount scratch disk
>   hosts: vm
>   connection: ssh
>   become: True
>   vars_files: 
> - vars/consultancy
>   roles: 
> - scratch
>
> - name: Destroy scratch
>   hosts: localhost
>   gather_facts: no
>   connection: local
>
>   vars_files: 
> - vars/gcp_vm
>
>   tasks:
> - name: Destroy disk
>   when: destroy == "yes"
>   gcp_compute_disk:
> name: "{{ scratch_disk_name }}"
> zone: "{{ zone }}"
> project: "{{ gcp_project }}"
> auth_kind: "{{ gcp_cred_kind }}"
> service_account_file: "{{ gcp_cred_file }}"
> state: absent
>
> Playbook call:
>
> ansible-playbook scratch.yml --extra-vars "instance_name=work 
> scratch_disk_name=wave destroy=no scratch_pathname=/data/wave"
>
> Result:
>
> PLAY [Add a scratch disk to an 

[ansible-project] Re: ansible ping fails, but can SSH to host just fine

2020-04-08 Thread Robert Egloff
Right after I posted this - I found the answer and I'll update it in case 
anyone else runs into this. 
As I was closing some of my many open tabs (bad about that) - I ran across 
this:

https://github.com/ansible/ansible/issues/19584

Someone suggested in this person's case to run this command: ansible all -u 
ec2-user -m ping -vvv

So I tried that command defining the user and it worked immediately. 

After a little more digging, the directory I was running Ansible in had an 
'ansible.cfg' file that was defining the user as 'root'. So it seems it was 
attempting to connect as root, but using the SSH key file for the 
ansible_account. After that, just moving out of my test directory proved 
that running the command 'vanilla' worked just fine. 

*[ansible_account@ansible_controller ~]$ ansible -m ping 
remote_serverWednesday 08 April 2020  14:39:18 -0500 (0:00:00.075)  
 0:00:00.075 ***remote_server | SUCCESS => {"changed": false,
"ping": "pong"}Wednesday 08 April 2020  14:39:20 -0500 (0:00:01.487)  
 0:00:01.562 
***===ping
 

 
1.49sPlaybook run took 0 days, 0 hours, 0 minutes, 1 
seconds[ansible_account@ansible_controller ~]$*


I figured it was some little detail I was missing and maybe it'll help 
someone out there :)

Happy DevOps-ing!



On Wednesday, April 8, 2020 at 3:33:17 PM UTC-4, Robert Egloff wrote:
>
> I'm sure it's something I'm doing... but I managed to create a playbook to 
> create my ansible user, add the SSH key, and all of that to a remote 
> server. 
> However, to get it to run - I need to use the --ask-pass parameter.
>
> ansible-playbook -i "remote_server," add_ans_user.yml -b --ask-pass  << 
> That works and creates the user just fine, which makes sense as it needs to 
> create the account as root. 
>
> After running the playbook to create the user, I can SSH without issues as 
> the user to the remote server, no password required - which means it should 
> be using the SSH key just fine. 
>
> The playbook adds the public key (key_file: 
> "/opt/ansible_account/.ssh/id_rsa.pub") - which seems to work for 
> authentication for this account. 
>
>
> [ansible_account@remote_server linux_small_plays]$ ssh remote_server
> Last login: Wed Apr  8 11:09:20 2020 from remote_server.domain.com
> [ansible_account@remote_server ~]$
>
> But when I attempt a ping with this account, it fails.
>
> [ansible_account@ansible_controller linux_small_plays]$ ansible -m ping 
> remote_server
> Wednesday 08 April 2020  14:14:38 -0500 (0:00:00.077)   0:00:00.077 
> ***
> remote_server | UNREACHABLE! => {
> "changed": false,
> "msg": "Failed to connect to the host via ssh: Permission denied 
> (publickey,gssapi-keyex,gssapi-with-mic,password).",
> "unreachable": true
> }
> Wednesday 08 April 2020  14:14:39 -0500 (0:00:00.335)   0:00:00.413 
> ***
>
> ===
> ping 
> 
>  
> 0.34s
> Playbook run took 0 days, 0 hours, 0 minutes, 0 seconds
> [ansible_account@ansible_controller linux_small_plays]$
>
> This is confusing me - because regular SSH from the Ansible Controller as 
> the ansible user I setup to the Remote_Server works just fine. If I use -b 
> to become and provide the password for root, it works just fine as well. 
>
> [ansible_account@ansible_controller linux_small_plays]$ ansible -m ping 
> remote_server -b --ask-pass
> SSH password:
> Wednesday 08 April 2020  14:23:19 -0500 (0:00:00.079)   0:00:00.079 
> ***
> remote_server | SUCCESS => {
> "changed": false,
> "ping": "pong"
> }
> Wednesday 08 April 2020  14:23:21 -0500 (0:00:01.393)   0:00:01.472 
> ***
>
> ===
> ping 
> 
>  
> 1.39s
> Playbook run took 0 days, 0 hours, 0 minutes, 1 seconds
> [ansible_account@ansible_controller linux_small_plays]$
>
> It seems to be an issue with the SSH key, but since that account seems to 
> work fine - I'm not sure right off where to look next. I have been doing 
> more verbose connections, but didn't want to post that wall of output just 
> yet - in case this is something obvious I'm doing wrong. 
>
> But on a simple "ssh - remote_host" - some of the information it 
> returns:
>
> debug1: Next authentication method: publickey
> debug1: Offering RSA public key: /opt/ansible_account/.ssh/id_rsa
>
> debug1: Server accepts key: pkalg ssh-rsa blen 535
>
> debug1: 

[ansible-project] ansible ping fails, but can SSH to host just fine

2020-04-08 Thread Robert Egloff
I'm sure it's something I'm doing... but I managed to create a playbook to 
create my ansible user, add the SSH key, and all of that to a remote 
server. 
However, to get it to run - I need to use the --ask-pass parameter.

ansible-playbook -i "remote_server," add_ans_user.yml -b --ask-pass  << 
That works and creates the user just fine, which makes sense as it needs to 
create the account as root. 

After running the playbook to create the user, I can SSH without issues as 
the user to the remote server, no password required - which means it should 
be using the SSH key just fine. 

The playbook adds the public key (key_file: 
"/opt/ansible_account/.ssh/id_rsa.pub") - which seems to work for 
authentication for this account. 


[ansible_account@remote_server linux_small_plays]$ ssh remote_server
Last login: Wed Apr  8 11:09:20 2020 from remote_server.domain.com
[ansible_account@remote_server ~]$

But when I attempt a ping with this account, it fails.

[ansible_account@ansible_controller linux_small_plays]$ ansible -m ping 
remote_server
Wednesday 08 April 2020  14:14:38 -0500 (0:00:00.077)   0:00:00.077 
***
remote_server | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied 
(publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}
Wednesday 08 April 2020  14:14:39 -0500 (0:00:00.335)   0:00:00.413 
***
===
ping 

 
0.34s
Playbook run took 0 days, 0 hours, 0 minutes, 0 seconds
[ansible_account@ansible_controller linux_small_plays]$

This is confusing me - because regular SSH from the Ansible Controller as 
the ansible user I setup to the Remote_Server works just fine. If I use -b 
to become and provide the password for root, it works just fine as well. 

[ansible_account@ansible_controller linux_small_plays]$ ansible -m ping 
remote_server -b --ask-pass
SSH password:
Wednesday 08 April 2020  14:23:19 -0500 (0:00:00.079)   0:00:00.079 
***
remote_server | SUCCESS => {
"changed": false,
"ping": "pong"
}
Wednesday 08 April 2020  14:23:21 -0500 (0:00:01.393)   0:00:01.472 
***
===
ping 

 
1.39s
Playbook run took 0 days, 0 hours, 0 minutes, 1 seconds
[ansible_account@ansible_controller linux_small_plays]$

It seems to be an issue with the SSH key, but since that account seems to 
work fine - I'm not sure right off where to look next. I have been doing 
more verbose connections, but didn't want to post that wall of output just 
yet - in case this is something obvious I'm doing wrong. 

But on a simple "ssh - remote_host" - some of the information it 
returns:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /opt/ansible_account/.ssh/id_rsa

debug1: Server accepts key: pkalg ssh-rsa blen 535

debug1: Authentication succeeded (publickey).
Authenticated to remote_host ([192.168.1.10]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0

***Also - I changed the server names and account names - I'm not really 
using an underscore in any of them :)*



-- 
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/0133cfdb-e8e4-43f3-aa02-a15ea630ae46%40googlegroups.com.


Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Suresh Karpurapu
awesome, it really helped for my requirement. thank you so much Vladimir,

Regards,
Suresh

On Wed, Apr 8, 2020 at 9:53 PM Vladimir Botka  wrote:

> On Wed, 8 Apr 2020 19:55:04 +0530
> Suresh Karpurapu  wrote:
>
> > ... i would like to display all the entries.
> >
> > # cat mounts.csv
> > host,remote_path,mnt_path
> > host1,nfsvol1,mount1
> > host1,nfsvol2,mount2
> > host1,nfsvol3,mount3
> > host2,nfsvol1,mount1
> > host2,nfsvol2,mount2
> > host2,nfsvol3,mount3
> >
> > # cat mounts.yml
> > ---
> > - name: mount the nfsshare in client side
> >   hosts: localhost
> >   gather_facts: false
> >   become: yes
> >   tasks:
> > - name: reading volume info from csv
> >   read_csv:
> > path: "{{ playbook_dir }}/mounts.csv"
> >   register: sources
> >   delegate_to: localhost
> > - name: Grouping host and volume information
> >   add_host:
> > name: "{{ item.host }}"
> > groups: nfsgroup
> > var1: "{{ item.remote_path }}"
> > var2: "{{ item.mnt_path }}"
> >   loop: "{{ sources.list }}"
>
> Use "groupby" filter. For example
> https://jinja.palletsprojects.com/en/master/templates/#groupby
>
>   add_host:
> name: "{{ item.0 }}"
> groups: nfsgroup
> var1: "{{ item.1|json_query('[].remote_path') }}"
> var2: "{{ item.1|json_query('[].mnt_path') }}"
>   loop: "{{ sources.list|groupby('host') }}"
>
> > - name: list volume details
> >   hosts: nfsgroup
> >   become: yes
> >   gather_facts: false
> >   tasks:
> > - debug:
> > msg:
> >   - "{{ inventory_hostname }}"
> >   - "{{ var1 }}"
> >   - "{{ var2 }}"
>
> You should receive lists of "remote_path" and "mnt_path" in var1 and var2
> respectively.
>
> ok: [host1] => {
> "msg": [
> "host1",
> [
> "nfsvol1",
> "nfsvol2",
> "nfsvol3"
> ],
> [
> "mount1",
> "mount2",
> "mount3"
> ]
> ]
> }
> ok: [host2] => {
> "msg": [
> "host2",
> [
> "nfsvol1",
> "nfsvol2",
> "nfsvol3"
> ],
> [
> "mount1",
> "mount2",
> "mount3"
> ]
> ]
> }
>
> HTH,
>
> -vlado
>

-- 
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/CAHedzh%2BvLkXFdEqyikyXnGSYWSTqopd6rgfhU0r%2BPu16biQsAg%40mail.gmail.com.


Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Vladimir Botka
On Wed, 8 Apr 2020 19:55:04 +0530
Suresh Karpurapu  wrote:

> ... i would like to display all the entries.
> 
> # cat mounts.csv
> host,remote_path,mnt_path
> host1,nfsvol1,mount1
> host1,nfsvol2,mount2
> host1,nfsvol3,mount3
> host2,nfsvol1,mount1
> host2,nfsvol2,mount2
> host2,nfsvol3,mount3
> 
> # cat mounts.yml
> ---
> - name: mount the nfsshare in client side
>   hosts: localhost
>   gather_facts: false
>   become: yes
>   tasks:
> - name: reading volume info from csv
>   read_csv:
> path: "{{ playbook_dir }}/mounts.csv"
>   register: sources
>   delegate_to: localhost
> - name: Grouping host and volume information
>   add_host:
> name: "{{ item.host }}"
> groups: nfsgroup
> var1: "{{ item.remote_path }}"
> var2: "{{ item.mnt_path }}"
>   loop: "{{ sources.list }}"

Use "groupby" filter. For example
https://jinja.palletsprojects.com/en/master/templates/#groupby

  add_host:
name: "{{ item.0 }}"
groups: nfsgroup
var1: "{{ item.1|json_query('[].remote_path') }}"
var2: "{{ item.1|json_query('[].mnt_path') }}"
  loop: "{{ sources.list|groupby('host') }}"

> - name: list volume details
>   hosts: nfsgroup
>   become: yes
>   gather_facts: false
>   tasks:
> - debug:
> msg:
>   - "{{ inventory_hostname }}"
>   - "{{ var1 }}"
>   - "{{ var2 }}"

You should receive lists of "remote_path" and "mnt_path" in var1 and var2
respectively.

ok: [host1] => {
"msg": [
"host1", 
[
"nfsvol1", 
"nfsvol2", 
"nfsvol3"
], 
[
"mount1", 
"mount2", 
"mount3"
]
]
}
ok: [host2] => {
"msg": [
"host2", 
[
"nfsvol1", 
"nfsvol2", 
"nfsvol3"
], 
[
"mount1", 
"mount2", 
"mount3"
]
]
}

HTH,

-vlado

-- 
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/20200408182343.2a8850b5%40gmail.com.


pgpP8suPR54HY.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Suresh Karpurapu
Initially, i tried your approach but engineer has to do more work to make
the format as we are planning to use playbook for nfs volume migration. we
have 1000's of servers with 100's volumes. Hence, the reason, we chosen the
csv format. I have been using inventory based host connection but it is
connecting even if volume is not required to mount/unmount on target host.

# cat nfsvolmigration/roles/volmount/tasks/volmount.yml
---
  - name: reading volume info from csv
read_csv:
  path: "{{ playbook_dir }}/roles/volmount/files/sources.csv"
register: sources
delegate_to: localhost
  - name: check the volume in fstab
shell: "grep {{ source.remote_path }} /etc/fstab|awk '{print $4}'"
loop: "{{ sources.list }}"
loop_control:
  loop_var: source
register: source
  - name: mounting the volume in the fstab file
mount:
  fstype: nfs
  opts: "{{ item.stdout_lines[0] }}"
  dump: "{{ fs_dump }}"
  passno: "{{ fsck_opt }}"
  src: "{{ item.source.remote_path }}"
  path: "{{ item.source.mnt_path }}"
  state: mounted
when: item.stdout != ""
loop: "{{ source.results }}"
...
# cat nfsvolmigration/roles/volunmount/tasks/volunmount.yml
---
  - name: "reading volume info from csv file"
read_csv:
  path: "{{ playbook_dir }}/roles/volunmount/files/sources.csv"
register: sources
delegate_to: localhost
  - name: check if the volumes are mounted
shell: mount -t nfs | grep "{{ source.remote_path }}" | awk '{print $1}'
args:
  warn: false
loop: "{{ sources.list }}"
loop_control:
  loop_var: source
register: mounts
  - name: unmount nfs_shares
shell: /bin/umount -lf {{ item.source.mnt_path }}
when: item.stdout != ""
loop: "{{ mounts.results }}"
  - name: unmount nfs_shares if there any
mount:
  path: "{{ item.source.mnt_path }}"
  src: "{{ item.source.remote_path }}"
  state: unmounted
when: item.stdout != ""
loop: "{{ mounts.results }}"
...

Regards,
Suresh


On Wed, Apr 8, 2020 at 8:48 PM Pandu jh  wrote:

>  format your csv data file to inventory file as below. Then the variables
> can be used to the respective hosts directly.
> Hope this helps.
>
> Use sed and awk for formatting the inventory file from CSV file
>
> sed 's/,/ /g' mounts
> awk -F' ' -vOFS=' ' '{ $2 = "remote_path=" $2  }2' mounts
> awk -F' ' -vOFS=' ' '{ $3 = "mnt_path=" $3  }3' /tmp/mounts
>
>
>  # cat mounts
> host1 remote_path=nfsvol1 mnt_path=mount1
> host1 remote_path=nfsvol2 mnt_path=mount2
> host1 remote_path=nfsvol3 mnt_path=mount3
> host2 remote_path=nfsvol1 mnt_path=mount1
> host2 remote_path=nfsvol2 mnt_path=mount2
> host2 remote_path=nfsvol3 mnt_path=mount3
>
>
>
> On Wednesday, 8 April 2020 20:07:27 UTC+5:30, Suresh Karpurapu wrote:
>>
>> thanks Vladimir, your suggestion helped a lot. Still, i am facing one
>> challenge while using add_host. I have the csv file with the same server
>> has different volumes. When i run the playbook, it is displaying last entry
>> associated to the same but i would like to display all the entries. Can you
>> suggest on the same?
>>
>> # cat mounts.csv
>> host,remote_path,mnt_path
>> host1,nfsvol1,mount1
>> host1,nfsvol2,mount2
>> host1,nfsvol3,mount3
>> host2,nfsvol1,mount1
>> host2,nfsvol2,mount2
>> host2,nfsvol3,mount3
>>
>> # cat mounts.yml
>> ---
>> - name: mount the nfsshare in client side
>>   hosts: localhost
>>   gather_facts: false
>>   become: yes
>>   tasks:
>> - name: reading volume info from csv
>>   read_csv:
>> path: "{{ playbook_dir }}/mounts.csv"
>>   register: sources
>>   delegate_to: localhost
>> - name: Grouping host and volume information
>>   add_host:
>> name: "{{ item.host }}"
>> groups: nfsgroup
>> var1: "{{ item.remote_path }}"
>> var2: "{{ item.mnt_path }}"
>>   loop: "{{ sources.list }}"
>> - name: list volume details
>>   hosts: nfsgroup
>>   become: yes
>>   gather_facts: false
>>   tasks:
>> - debug:
>> msg:
>>   - "{{ inventory_hostname }}"
>>   - "{{ var1 }}"
>>   - "{{ var2 }}"
>> ...
>>
>> Output:
>> ==
>> PLAY [list volume details]
>> **
>>
>> TASK [debug]
>> 
>> ok: [host1] => {
>> "msg": [
>> "host1",
>> "nfsvol3",
>> "mount3"
>> ]
>> }
>> ok: [host2] => {
>> "msg": [
>> "host2",
>> "nfsvol3",
>> "mount3"
>> ]
>> }
>>
>> PLAY RECAP
>> **
>> localhost  : ok=2changed=1unreachable=0
>>  failed=0

Re: [ansible-project] acme_certificate with *.domain.name

2020-04-08 Thread Patric Buskas
Thank you all!

I found a typo in a variable. It's working as expected now.
:-)

On Wed, Apr 8, 2020 at 3:00 PM 'Felix Fontein' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi Edoardo,
>
> for route53, you can simply set `wait: yes` (see
>
> https://docs.ansible.com/ansible/latest/modules/route53_module.html#parameter-wait
> )
> and the module will only return once all DNS servers have been updated.
> Also takes some time (feels like forever ;) ), but a lot less than 20
> minutes.
>
> For general waits, there's also the pause module
> (https://docs.ansible.com/ansible/latest/modules/pause_module.html).
> For example:
>
>   - name: Wait for DNS entries to propagate
> pause:
>   seconds: 10
>
> For 20 minutes your solution is better though, since you can see that
> something is still happening once per minute ;)
>
> Cheers,
> Felix
>
>
> > I created this snippet to wait for DNS resolution before proceeding
> > with the ACME verification.
> >
> > - name: '{{ certificate.common_name }} | "Wax on, wax off"'
> >   debug:
> > msg: "{{ dns_txt_record }} <=> {{ item.1 | first }}"
> >   when: acme_challenge is changed
> >   loop: "{{ acme_challenge.challenge_data_dns | dictsort }}"
> >   until: dns_txt_record == item.1[0]
> >   # If the until parameter isn’t defined, the value for the
> > retries parameter is forced to 1.
> >   #
> >
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html?highlight=delay#id9
> >   retries: 20
> >   delay: 60
> >   vars:
> > dns_txt_record: "{{  lookup('dig', item.0, 'qtype=TXT')  }}"
> >
> > This is tailored for AWS Route53 but be easy to adapt. It performs a
> > DNS TXT request once every minute checking for the ACME challenge
> > text until it's found or reaches 20 minutes.
> >
> > 20 minutes is a very long time but please note than this is run
> > locally (on operator machine or server) and as such I preferred to
> > keep a longer buffer (as DNS propagation may take time). As until is
> > used it stops waiting once the entry is found, the wait time depends
> > on how fast the DNS entry is found so there is no penalty if it's
> > found sooner.
> >
> > As the check is then performed from the ACME provider servers, this
> > does not ensure 100% that when the record is available to you is
> > available also to them, but in almost all cases this will be true as
> > propagation to their system will be faster or equal than propagation
> > to your system. This check has proven very effective for the last 2
> > years, but YMMV :)
> >
> > You can obviously tweak retries and delay to suit your network
> > conditions.
> >
> > Hope it helps!
> >
> > Best,
> > Edoardo
> >
> >
>
> --
> 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/20200408145956.67c6d0f3%40utsjoki
> .
>

-- 
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/CABG_dsuWJ5_1XQz7S2QUEugPpN1drdi%3DfjT77kzKs7YdT5DWMw%40mail.gmail.com.


Re: [ansible-project] Re: Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Suresh Karpurapu
Hi Pandu,

the playbook is working if the csv has single entry associated to the host,
but same playbook is failing if the same host has multiple variables
entries. I tried many ways by using inventory but no luck. Finally, i
choose read_csv and add_host.  If you have working example with inventory,
can you please share with me?

# cat mounts.csv[ working as expected]
host,remote_path,mnt_path
host1,nfsvol1,mount1
host2,nfsvol2,mount2
host3,nfsvol3,mount3


# cat mounts.csv[ working, but it is considering last entry only]
host,remote_path,mnt_path
host1,nfsvol1,mount1
host1,nfsvol2,mount2
host1,nfsvol3,mount3
host2,nfsvol1,mount1
host2,nfsvol2,mount2
host2,nfsvol3,mount3

Regards,
Suresh



On Wed, Apr 8, 2020 at 8:09 PM Pandu jh  wrote:

> Can you try to format your csv data to inventory as below.
>
>  # cat mounts
> host,remote_path,mnt_path
> host1,nfsvol1,mount1
> host1,nfsvol2,mount2
> host1,nfsvol3,mount3
> host2,nfsvol1,mount1
> host2,nfsvol2,mount2
> host2,nfsvol3,mount3
>
> On Saturday, 21 March 2020 00:35:05 UTC+5:30, J wrote:
>>
>>
>> My csv file looks like this and its called ip.csv:
>>
>>
>>
>> ip,username,host
>>
>> 10.1.1.1,rchantif1,mechlab
>>
>> 10.1.1.2,rchans01,contlab
>>
>> 192.168.2.142,vagrant
>>
>>
>>
>>
>>
>> I’m using the read_csv: module to access the data
>>
>>
>>
>> What I did is create a playbook that prints what you are looking for the
>> then I followed up on another task an example of logging into a host with
>> the username and IP. I’m not 100% sure what you want to do but hopefully
>> with the info I provided you have a start to your playbook/tasks.
>>
>>
>>
>> ---
>>
>> - name: read items from csv and store as vars
>>
>>   hosts: localhost
>>
>>   become: false
>>
>>   tasks:
>>
>> - name: read_csv
>>
>>   read_csv:
>>
>> path: ip.csv
>>
>>   register: ip
>>
>> - name: print csv items
>>
>>   debug:
>>
>> msg: "{{ip.list.2.ip}} {{ip.list.2.username}} {{ip.list.2.host}}"
>>
>> - name:
>>
>>   shell: "ssh {{ip.list.2.username}}@{{ip.list.2.ip}} 'ls -la'"
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wednesday, March 18, 2020 at 10:28:27 AM UTC-4, Pandu jh wrote:
>>
>>> I have a CSV file that contains the IP's and it's variables.
>>> I need to use the details to log in to the host and use the respective
>>> variable's value of the specfic IP's.
>>>
>>> Please help me out with this.
>>>
>>> # cat AnsibleTest.csv
>>> ip,var1,var2
>>> 10.1.1.1,rchantif1,mechlab
>>> 10.1.1.2,rchans01,contlab
>>>
>>
>> On Wednesday, March 18, 2020 at 10:28:27 AM UTC-4, Pandu jh wrote:
>>>
>>> I have a CSV file that contains the IP's and it's variables.
>>> I need to use the details to log in to the host and use the respective
>>> variable's value of the specfic IP's.
>>>
>>> Please help me out with this.
>>>
>>> # cat AnsibleTest.csv
>>> ip,var1,var2
>>> 10.1.1.1,rchantif1,mechlab
>>> 10.1.1.2,rchans01,contlab
>>>
>>
>> On Wednesday, March 18, 2020 at 10:28:27 AM UTC-4, Pandu jh wrote:
>>>
>>> I have a CSV file that contains the IP's and it's variables.
>>> I need to use the details to log in to the host and use the respective
>>> variable's value of the specfic IP's.
>>>
>>> Please help me out with this.
>>>
>>> # cat AnsibleTest.csv
>>> ip,var1,var2
>>> 10.1.1.1,rchantif1,mechlab
>>> 10.1.1.2,rchans01,contlab
>>>
>> --
> 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/c586db4f-82f6-4560-b567-9ca1f125e342%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/CAHedzhJsQV0SZG_LPpQ%3DESh9eMhvcBE1LnWhtdMbM6wQjG_DAA%40mail.gmail.com.


Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Pandu jh
 format your csv data file to inventory file as below. Then the variables 
can be used to the respective hosts directly.
Hope this helps.

Use sed and awk for formatting the inventory file from CSV file

sed 's/,/ /g' mounts
awk -F' ' -vOFS=' ' '{ $2 = "remote_path=" $2  }2' mounts
awk -F' ' -vOFS=' ' '{ $3 = "mnt_path=" $3  }3' /tmp/mounts


 # cat mounts
host1 remote_path=nfsvol1 mnt_path=mount1
host1 remote_path=nfsvol2 mnt_path=mount2
host1 remote_path=nfsvol3 mnt_path=mount3
host2 remote_path=nfsvol1 mnt_path=mount1
host2 remote_path=nfsvol2 mnt_path=mount2
host2 remote_path=nfsvol3 mnt_path=mount3



On Wednesday, 8 April 2020 20:07:27 UTC+5:30, Suresh Karpurapu wrote:
>
> thanks Vladimir, your suggestion helped a lot. Still, i am facing one 
> challenge while using add_host. I have the csv file with the same server 
> has different volumes. When i run the playbook, it is displaying last entry 
> associated to the same but i would like to display all the entries. Can you 
> suggest on the same?
>
> # cat mounts.csv
> host,remote_path,mnt_path
> host1,nfsvol1,mount1
> host1,nfsvol2,mount2
> host1,nfsvol3,mount3
> host2,nfsvol1,mount1
> host2,nfsvol2,mount2
> host2,nfsvol3,mount3
>
> # cat mounts.yml
> ---
> - name: mount the nfsshare in client side
>   hosts: localhost
>   gather_facts: false
>   become: yes
>   tasks:
> - name: reading volume info from csv
>   read_csv:
> path: "{{ playbook_dir }}/mounts.csv"
>   register: sources
>   delegate_to: localhost
> - name: Grouping host and volume information
>   add_host:
> name: "{{ item.host }}"
> groups: nfsgroup
> var1: "{{ item.remote_path }}"
> var2: "{{ item.mnt_path }}"
>   loop: "{{ sources.list }}"
> - name: list volume details
>   hosts: nfsgroup
>   become: yes
>   gather_facts: false
>   tasks:
> - debug:
> msg:
>   - "{{ inventory_hostname }}"
>   - "{{ var1 }}"
>   - "{{ var2 }}"
> ...
>
> Output:
> ==
> PLAY [list volume details] 
> **
>
> TASK [debug] 
> 
> ok: [host1] => {
> "msg": [
> "host1",
> "nfsvol3",
> "mount3"
> ]
> }
> ok: [host2] => {
> "msg": [
> "host2",
> "nfsvol3",
> "mount3"
> ]
> }
>
> PLAY RECAP 
> **
> localhost  : ok=2changed=1unreachable=0   
>  failed=0skipped=0rescued=0ignored=0
> host1   : ok=1changed=0unreachable=0failed=0skipped=0   
>  rescued=0ignored=0
> host2   : ok=1changed=0unreachable=0failed=0skipped=0   
>  rescued=0ignored=0
>
>
> On Sat, Mar 21, 2020 at 3:58 AM Vladimir Botka  > wrote:
>
>> On Wed, 18 Mar 2020 07:28:27 -0700 (PDT)
>> Pandu jh > wrote:
>>
>> > I have a CSV file that contains the IP's and it's variables.
>> > I need to use the details to log in to the host and use the respective 
>> > variable's value of the specfic IP's.
>> > 
>> > # cat AnsibleTest.csv
>> > ip,var1,var2
>> > 10.1.1.1,rchantif1,mechlab
>> > 10.1.1.2,rchans01,contlab
>>
>> Read the the file and create new group of hosts in the first play. The use
>> the group in the second play. For example
>>
>> shell> cat playbook.yml
>> - hosts: localhost
>>   gather_facts: false
>>   tasks:
>> - read_csv:
>> path: AnsibleTest.csv
>>   register: myhosts
>> - add_host:
>> name: '{{ item.ip }}'
>> groups: test_01
>> var1: "{{ item.var1 }}"
>> var2: "{{ item.var2 }}"
>>   loop: "{{ myhosts.list }}"
>>
>> - hosts: test_01
>>   gather_facts: false
>>   tasks:
>> - debug:
>> msg:
>>   - "{{ inventory_hostname }}"
>>   - "{{ var1 }}"
>>   - "{{ var2 }}"
>>
>> shell> ansible-playbook playbook.yml
>> ...
>> ok: [10.1.1.1] => {
>> "msg": [
>> "10.1.1.1", 
>> "rchantif1", 
>> "mechlab"
>> ]
>> }
>> ok: [10.1.1.2] => {
>> "msg": [
>> "10.1.1.2", 
>> "rchans01", 
>> "contlab"
>> ]
>> }
>>
>> HTH,
>>
>> -vlado
>>
>> -- 
>> 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/20200320232753.5d772d73%40gmail.com
>> .
>>
>

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

Re: [ansible-project] Can only run playbooks on localhost with AWX

2020-04-08 Thread Michael Mullay
Hi,

Have you made sure that /tests/test.yml contains 'hosts: all'? If
you had some other value, say for testing, then it would instead try to use
that value which would then just treat the hosts you told it to use within
AWX as a filter. And thus any hosts in your AWX inventory that don't match
what you have actually defined in the playbook would be ignored.
PS- this forum is for Ansible only, not AWX. It has its own group(s).

On Wed, Apr 8, 2020 at 6:43 AM Umut Erol Kaçar  wrote:

> Hello everyone,
>
> I'm currently working on AWX 9.0.1.0 with Ansible 2.8.5. Here's some info
> about my workflow:
>
>-
>
>I write playbooks/roles on my own machine, using Role Directory
>Structure, created by ansible-galaxy init 
>-
>
>I push these roles to GitHub, which is already connected to our AWX
>server as a project and it gets synched by scheduled jobs.
>-
>
>When creating a new template, after choosing our synched GitHub
>project, on the PLAYBOOK dropdown, I see all roles' like
>/tests/test.yml
>-
>
>I also choose the target machines correctly on the INVENTORY field.
>The one I choose is a smart inventory, derived from a dynamic inventory
>sourced by a vSphere environment.
>-
>
>The problem is: When I run this newly created template on AWX, it runs
>without errors but it runs on localhost only, not on the machines I've
>chosen on the INVENTORY field.
>
> I see there is an inventory file on tests\ directory and it has the only
> entry as localhost.
>
> I emptied this inventory file and even deleted it but it still runs only
> on localhost.
>
> What am I missing?
>
> Thanks in advance.
>
> --
> 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/788852d9-0ff7-4f69-9a95-ba5f94550535%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/CAH4rTPv3TWyVgYJLAx8LsmTdi0NX4gzjOu%2BrHRLBMFotf9-CrQ%40mail.gmail.com.


[ansible-project] Re: Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Pandu jh
Can you try to format your csv data to inventory as below.

 # cat mounts
host,remote_path,mnt_path
host1,nfsvol1,mount1
host1,nfsvol2,mount2
host1,nfsvol3,mount3
host2,nfsvol1,mount1
host2,nfsvol2,mount2
host2,nfsvol3,mount3

On Saturday, 21 March 2020 00:35:05 UTC+5:30, J wrote:
>
>
> My csv file looks like this and its called ip.csv:
>
>  
>
> ip,username,host
>
> 10.1.1.1,rchantif1,mechlab
>
> 10.1.1.2,rchans01,contlab
>
> 192.168.2.142,vagrant
>
>  
>
>  
>
> I’m using the read_csv: module to access the data
>
>  
>
> What I did is create a playbook that prints what you are looking for the 
> then I followed up on another task an example of logging into a host with 
> the username and IP. I’m not 100% sure what you want to do but hopefully 
> with the info I provided you have a start to your playbook/tasks.
>
>  
>
> ---
>
> - name: read items from csv and store as vars
>
>   hosts: localhost
>
>   become: false
>
>   tasks:
>
> - name: read_csv
>
>   read_csv:
>
> path: ip.csv
>
>   register: ip
>
> - name: print csv items
>
>   debug:
>
> msg: "{{ip.list.2.ip}} {{ip.list.2.username}} {{ip.list.2.host}}"
>
> - name:
>
>   shell: "ssh {{ip.list.2.username}}@{{ip.list.2.ip}} 'ls -la'"
>
>
>
>
>
>
>
>
> On Wednesday, March 18, 2020 at 10:28:27 AM UTC-4, Pandu jh wrote:
>
>> I have a CSV file that contains the IP's and it's variables.
>> I need to use the details to log in to the host and use the respective 
>> variable's value of the specfic IP's.
>>
>> Please help me out with this.
>>
>> # cat AnsibleTest.csv
>> ip,var1,var2
>> 10.1.1.1,rchantif1,mechlab
>> 10.1.1.2,rchans01,contlab
>>
>
> On Wednesday, March 18, 2020 at 10:28:27 AM UTC-4, Pandu jh wrote:
>>
>> I have a CSV file that contains the IP's and it's variables.
>> I need to use the details to log in to the host and use the respective 
>> variable's value of the specfic IP's.
>>
>> Please help me out with this.
>>
>> # cat AnsibleTest.csv
>> ip,var1,var2
>> 10.1.1.1,rchantif1,mechlab
>> 10.1.1.2,rchans01,contlab
>>
>
> On Wednesday, March 18, 2020 at 10:28:27 AM UTC-4, Pandu jh wrote:
>>
>> I have a CSV file that contains the IP's and it's variables.
>> I need to use the details to log in to the host and use the respective 
>> variable's value of the specfic IP's.
>>
>> Please help me out with this.
>>
>> # cat AnsibleTest.csv
>> ip,var1,var2
>> 10.1.1.1,rchantif1,mechlab
>> 10.1.1.2,rchans01,contlab
>>
>

-- 
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/c586db4f-82f6-4560-b567-9ca1f125e342%40googlegroups.com.


Re: [ansible-project] Need to pass variable and hostname to a playbook from CSV file.

2020-04-08 Thread Suresh Karpurapu
thanks Vladimir, your suggestion helped a lot. Still, i am facing one
challenge while using add_host. I have the csv file with the same server
has different volumes. When i run the playbook, it is displaying last entry
associated to the same but i would like to display all the entries. Can you
suggest on the same?

# cat mounts.csv
host,remote_path,mnt_path
host1,nfsvol1,mount1
host1,nfsvol2,mount2
host1,nfsvol3,mount3
host2,nfsvol1,mount1
host2,nfsvol2,mount2
host2,nfsvol3,mount3

# cat mounts.yml
---
- name: mount the nfsshare in client side
  hosts: localhost
  gather_facts: false
  become: yes
  tasks:
- name: reading volume info from csv
  read_csv:
path: "{{ playbook_dir }}/mounts.csv"
  register: sources
  delegate_to: localhost
- name: Grouping host and volume information
  add_host:
name: "{{ item.host }}"
groups: nfsgroup
var1: "{{ item.remote_path }}"
var2: "{{ item.mnt_path }}"
  loop: "{{ sources.list }}"
- name: list volume details
  hosts: nfsgroup
  become: yes
  gather_facts: false
  tasks:
- debug:
msg:
  - "{{ inventory_hostname }}"
  - "{{ var1 }}"
  - "{{ var2 }}"
...

Output:
==
PLAY [list volume details]
**

TASK [debug]

ok: [host1] => {
"msg": [
"host1",
"nfsvol3",
"mount3"
]
}
ok: [host2] => {
"msg": [
"host2",
"nfsvol3",
"mount3"
]
}

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


On Sat, Mar 21, 2020 at 3:58 AM Vladimir Botka  wrote:

> On Wed, 18 Mar 2020 07:28:27 -0700 (PDT)
> Pandu jh  wrote:
>
> > I have a CSV file that contains the IP's and it's variables.
> > I need to use the details to log in to the host and use the respective
> > variable's value of the specfic IP's.
> >
> > # cat AnsibleTest.csv
> > ip,var1,var2
> > 10.1.1.1,rchantif1,mechlab
> > 10.1.1.2,rchans01,contlab
>
> Read the the file and create new group of hosts in the first play. The use
> the group in the second play. For example
>
> shell> cat playbook.yml
> - hosts: localhost
>   gather_facts: false
>   tasks:
> - read_csv:
> path: AnsibleTest.csv
>   register: myhosts
> - add_host:
> name: '{{ item.ip }}'
> groups: test_01
> var1: "{{ item.var1 }}"
> var2: "{{ item.var2 }}"
>   loop: "{{ myhosts.list }}"
>
> - hosts: test_01
>   gather_facts: false
>   tasks:
> - debug:
> msg:
>   - "{{ inventory_hostname }}"
>   - "{{ var1 }}"
>   - "{{ var2 }}"
>
> shell> ansible-playbook playbook.yml
> ...
> ok: [10.1.1.1] => {
> "msg": [
> "10.1.1.1",
> "rchantif1",
> "mechlab"
> ]
> }
> ok: [10.1.1.2] => {
> "msg": [
> "10.1.1.2",
> "rchans01",
> "contlab"
> ]
> }
>
> HTH,
>
> -vlado
>
> --
> 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/20200320232753.5d772d73%40gmail.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/CAHedzhKGSj%2Bdc%2BG_GCvC-xvVja2a4zt46-%2BXV-oHuW_wHTLLEw%40mail.gmail.com.


[ansible-project] Can only run playbooks on localhost with AWX

2020-04-08 Thread Umut Erol Kaçar


Hello everyone,

I'm currently working on AWX 9.0.1.0 with Ansible 2.8.5. Here's some info 
about my workflow:

   - 
   
   I write playbooks/roles on my own machine, using Role Directory 
   Structure, created by ansible-galaxy init 
   - 
   
   I push these roles to GitHub, which is already connected to our AWX 
   server as a project and it gets synched by scheduled jobs.
   - 
   
   When creating a new template, after choosing our synched GitHub project, 
   on the PLAYBOOK dropdown, I see all roles' like /tests/test.yml
   - 
   
   I also choose the target machines correctly on the INVENTORY field. The 
   one I choose is a smart inventory, derived from a dynamic inventory sourced 
   by a vSphere environment.
   - 
   
   The problem is: When I run this newly created template on AWX, it runs 
   without errors but it runs on localhost only, not on the machines I've 
   chosen on the INVENTORY field.
   
I see there is an inventory file on tests\ directory and it has the only 
entry as localhost.

I emptied this inventory file and even deleted it but it still runs only on 
localhost.

What am I missing?

Thanks in advance.

-- 
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/788852d9-0ff7-4f69-9a95-ba5f94550535%40googlegroups.com.


Re: [ansible-project] Re: How to increase VM OS disk, from template, using ansible vmware guest module

2020-04-08 Thread Bhanu Prakash
Than you so much .. I was thinking that's for additional disk, but not for
OS disk .. It worked ..

  disk:
  - size_gb: 60
type: thin
datastore: "test"


Thanks and Regards

Bhanu Prakash K

On Wed, Apr 8, 2020 at 6:23 PM David Foley  wrote:

> Hi Bhanu,
>
> Are you trying to Deploy From Template but to Increase the Disk , if so a
> simple
>
> vm_disk:
>   disk1:
> size_gb: 10
> type: thin
> datastore: storage001
>
> What is not supported is the decrease the disk size
>
> --
> 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/c679a37b-3281-4733-86e7-47b0f80ebb60%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/CAMJn1KM9zK-aCESUVsFXOHKKqHNzOSvTV66RVYr-gkap%3DXB3MQ%40mail.gmail.com.


Re: [ansible-project] Ansible Tower error of Deploying Dynatrace Oneagent on Windows Host | "unexpected rc from install C:\Temp\dynatrace-oneagent-windows-latest.exe: see rc, stdout and stderr for mor

2020-04-08 Thread Stefan Hornburg (Racke)
On 4/8/20 3:33 PM, Richard Jusay wrote:
> Hi,
> 
> I'm installing Dynatrace oneagent on Windows server, successfully downloaded 
> the installer but it wont continue the
> installation because of this error.

Hello Richard,

please reach out to RedHat Support, this list is only for Ansible and not for 
Tower nor AWX.

Regards
 Racke

> 
> *Ansible Tower*
> Play: dynatrace oneagent install on windows
> Task: install:execute oneagent install file
> Module: win_package
> 
> {
> "stderr_lines": [],
> "_ansible_no_log": false,
> "stdout": "",
> "changed": false,
> "reboot_required": false,
> "stderr": "",
> "rc": 1602,
> "msg": "unexpected rc from install 
> C:\Temp\dynatrace-oneagent-windows-latest.exe: see rc, stdout and stderr for 
> more
> details",
> "stdout_lines": []
> }
> 
> *Exact Error:*
> TASK [install: execute oneagent install file] 
> **
> fatal: [10.250.8.179]: FAILED! => {"changed": false, "msg": "unexpected rc 
> from install
> C:\Temp\dynatrace-oneagent-windows-latest.exe: see rc, stdout and stderr for 
> more details", "rc": 1602,
> "reboot_required": false, "stderr": "", "stderr_lines": [], "stdout": "", 
> "stdout_lines": []}
> 
> 
> 
> *Playbook:*
> 
> 
>   dynatrace oneagent install on windows
> 
> 
>   hosts_group -> inventory group of hosts to execute playbook on
> 
> 
>   dt_api_endpoint -> dynatrace environment api endpoint (include trailing /)
> 
> 
>   dt_api_token -> dynatrace api install token
> 
> 
>   dt_host_group: -> dynatrace host group name
> 
> 
>   dt_app_log_content_access: -> flag to enable or disable log analytics on 
> host (0 or 1)
> 
> 
>   dt_infra_only: -> flag to set cloud infrastructure monitoring mode on host 
> (0 or 1)
> 
> 
>   {65E3C889-BF02-4A22-9E22-5DCA88789582} v1.183.109 - live
> 
> 
>   {73CFAADA-499D-4B5F-A7D4-9687DDBDCAF5} v1.183.151 - practice
> 
> 
> 
>   *
> 
> 
> *hosts: "{{ hosts_group }}"
> vars:
> * dt_product_id: '{65E3C889-BF02-4A22-9E22-5DCA88789582}'
> name: "dynatrace oneagent install on windows"
> tasks:
> 
> |name: "validate ansible tower execution on windows" win_stat: path: 
> C:\Temp register: temp_dir |
> 
>   o name: "check if oneagent is already installed via windows service 
> registry key"
> win_reg_stat:
> path: HKLM:\SYSTEM\CurrentControlSet\Services\Dynatrace OneAgent
> name: DisplayName
> register: installed
>   o name: "download oneagent install file"
> win_get_url:
> url: "{{ dt_api_endpoint 
> }}deployment/installer/agent/windows/default/latest?Api-Token={{ dt_api_token
> }}=x86=default"
> dest: C:\Temp\dynatrace-oneagent-windows-latest.exe
>   o name: "install: execute oneagent install file"
> win_package:
> product_id: "{{ dt_product_id }}"
> path: C:\Temp\dynatrace-oneagent-windows-latest.exe
> arguments:
>   + HOST_GROUP="{{ dt_host_group }}"
>   + APP_LOG_CONTENT_ACCESS="{{ dt_app_log_content_access }}"
>   + INFRA_ONLY="{{ dt_infra_only }}"
> state: present
> when: installed.exists == False
>   o name: "update: validate existing oneagent product id exists"
> win_reg_stat:
> path: 
> "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{ 
> dt_product_id }}"
> name: DisplayName
> register: uninstall
> when: installed.exists == True
>   o name: "update: uninstall existing oneagent package"
> win_package:
> product_id: "{{ dt_product_id }}"
> state: absent
> when: installed.exists == True and uninstall.exists == True
>   o name: "update: execute oneagent install file"
> win_package:
> path: C:\Temp\dynatrace-oneagent-windows-latest.exe
> product_id: "{{ dt_product_id }}"
> arguments:
>   + HOST_GROUP="{{ dt_host_group }}"
>   + APP_LOG_CONTENT_ACCESS="{{ dt_app_log_content_access }}"
>   + INFRA_ONLY="{{ dt_infra_only }}"
> state: present
> when: installed.exists == True and uninstall.exists == True
> 
> -- 
> 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/085b82df-bd65-406d-bb22-0efbd5bb3ec7%40googlegroups.com
> .


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa 

[ansible-project] Ansible Tower error of Deploying Dynatrace Oneagent on Windows Host | "unexpected rc from install C:\Temp\dynatrace-oneagent-windows-latest.exe: see rc, stdout and stderr for more de

2020-04-08 Thread Richard Jusay


Hi,

I'm installing Dynatrace oneagent on Windows server, successfully 
downloaded the installer but it wont continue the installation because of 
this error.

*Ansible Tower*
Play: dynatrace oneagent install on windows
Task: install:execute oneagent install file
Module: win_package

{
"stderr_lines": [],
"_ansible_no_log": false,
"stdout": "",
"changed": false,
"reboot_required": false,
"stderr": "",
"rc": 1602,
"msg": "unexpected rc from install 
C:\Temp\dynatrace-oneagent-windows-latest.exe: see rc, stdout and stderr 
for more details",
"stdout_lines": []
}

*Exact Error:*
TASK [install: execute oneagent install file] 
**
fatal: [10.250.8.179]: FAILED! => {"changed": false, "msg": "unexpected rc 
from install C:\Temp\dynatrace-oneagent-windows-latest.exe: see rc, stdout 
and stderr for more details", "rc": 1602, "reboot_required": false, 
"stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}



*Playbook:*
dynatrace oneagent install on windows hosts_group -> inventory group of 
hosts to execute playbook on dt_api_endpoint -> dynatrace environment api 
endpoint (include trailing /) dt_api_token -> dynatrace api install token 
dt_host_group: 
-> dynatrace host group name dt_app_log_content_access: -> flag to enable 
or disable log analytics on host (0 or 1) dt_infra_only: -> flag to set 
cloud infrastructure monitoring mode on host (0 or 1) 
{65E3C889-BF02-4A22-9E22-5DCA88789582} 
v1.183.109 - live {73CFAADA-499D-4B5F-A7D4-9687DDBDCAF5} v1.183.151 - 
practice 
--

   - 

*hosts: "{{ hosts_group }}" vars: * dt_product_id: 
   '{65E3C889-BF02-4A22-9E22-5DCA88789582}'
   name: "dynatrace oneagent install on windows"
   tasks: 
   
   name: "validate ansible tower execution on windows"win_stat:  path: 
C:\Tempregister: temp_dir
   
   - name: "check if oneagent is already installed via windows service 
  registry key"
  win_reg_stat:
  path: HKLM:\SYSTEM\CurrentControlSet\Services\Dynatrace OneAgent
  name: DisplayName
  register: installed 
  - name: "download oneagent install file"
  win_get_url:
  url: "{{ dt_api_endpoint 
  }}deployment/installer/agent/windows/default/latest?Api-Token={{ 
  dt_api_token }}=x86=default"
  dest: C:\Temp\dynatrace-oneagent-windows-latest.exe 
  - name: "install: execute oneagent install file"
  win_package:
  product_id: "{{ dt_product_id }}"
  path: C:\Temp\dynatrace-oneagent-windows-latest.exe
  arguments: 
 - HOST_GROUP="{{ dt_host_group }}" 
 - APP_LOG_CONTENT_ACCESS="{{ dt_app_log_content_access }}" 
 - INFRA_ONLY="{{ dt_infra_only }}"
 state: present
 when: installed.exists == False 
  - name: "update: validate existing oneagent product id exists"
  win_reg_stat:
  path: 
  "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{ 
  dt_product_id }}"
  name: DisplayName
  register: uninstall
  when: installed.exists == True 
  - name: "update: uninstall existing oneagent package"
  win_package:
  product_id: "{{ dt_product_id }}"
  state: absent
  when: installed.exists == True and uninstall.exists == True 
  - name: "update: execute oneagent install file"
  win_package:
  path: C:\Temp\dynatrace-oneagent-windows-latest.exe
  product_id: "{{ dt_product_id }}"
  arguments: 
 - HOST_GROUP="{{ dt_host_group }}" 
 - APP_LOG_CONTENT_ACCESS="{{ dt_app_log_content_access }}" 
 - INFRA_ONLY="{{ dt_infra_only }}"
 state: present
 when: installed.exists == True and uninstall.exists == True
  

-- 
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/085b82df-bd65-406d-bb22-0efbd5bb3ec7%40googlegroups.com.


Re: [ansible-project] acme_certificate with *.domain.name

2020-04-08 Thread 'Felix Fontein' via Ansible Project
Hi Edoardo,

for route53, you can simply set `wait: yes` (see
https://docs.ansible.com/ansible/latest/modules/route53_module.html#parameter-wait)
and the module will only return once all DNS servers have been updated.
Also takes some time (feels like forever ;) ), but a lot less than 20
minutes.

For general waits, there's also the pause module
(https://docs.ansible.com/ansible/latest/modules/pause_module.html).
For example:

  - name: Wait for DNS entries to propagate
pause:
  seconds: 10

For 20 minutes your solution is better though, since you can see that
something is still happening once per minute ;)

Cheers,
Felix


> I created this snippet to wait for DNS resolution before proceeding
> with the ACME verification.
> 
>     - name: '{{ certificate.common_name }} | "Wax on, wax off"'
>   debug:
>     msg: "{{ dns_txt_record }} <=> {{ item.1 | first }}"
>   when: acme_challenge is changed
>   loop: "{{ acme_challenge.challenge_data_dns | dictsort }}"
>   until: dns_txt_record == item.1[0]
>   # If the until parameter isn’t defined, the value for the
> retries parameter is forced to 1.
>   #
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html?highlight=delay#id9
>   retries: 20
>   delay: 60
>   vars:
>     dns_txt_record: "{{  lookup('dig', item.0, 'qtype=TXT')  }}"
> 
> This is tailored for AWS Route53 but be easy to adapt. It performs a
> DNS TXT request once every minute checking for the ACME challenge
> text until it's found or reaches 20 minutes.
> 
> 20 minutes is a very long time but please note than this is run
> locally (on operator machine or server) and as such I preferred to
> keep a longer buffer (as DNS propagation may take time). As until is
> used it stops waiting once the entry is found, the wait time depends
> on how fast the DNS entry is found so there is no penalty if it's
> found sooner.
> 
> As the check is then performed from the ACME provider servers, this
> does not ensure 100% that when the record is available to you is
> available also to them, but in almost all cases this will be true as
> propagation to their system will be faster or equal than propagation
> to your system. This check has proven very effective for the last 2
> years, but YMMV :)
> 
> You can obviously tweak retries and delay to suit your network
> conditions.
> 
> Hope it helps!
> 
> Best,
> Edoardo
> 
> 

-- 
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/20200408145956.67c6d0f3%40utsjoki.


Re: [ansible-project] acme_certificate with *.domain.name

2020-04-08 Thread Edoardo Tenani
I created this snippet to wait for DNS resolution before proceeding with
the ACME verification.

    - name: '{{ certificate.common_name }} | "Wax on, wax off"'
  debug:
    msg: "{{ dns_txt_record }} <=> {{ item.1 | first }}"
  when: acme_challenge is changed
  loop: "{{ acme_challenge.challenge_data_dns | dictsort }}"
  until: dns_txt_record == item.1[0]
  # If the until parameter isn’t defined, the value for the retries
parameter is forced to 1.
  #
https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html?highlight=delay#id9
  retries: 20
  delay: 60
  vars:
    dns_txt_record: "{{  lookup('dig', item.0, 'qtype=TXT')  }}"

This is tailored for AWS Route53 but be easy to adapt. It performs a DNS
TXT request once every minute checking for the ACME challenge text until
it's found or reaches 20 minutes.

20 minutes is a very long time but please note than this is run locally
(on operator machine or server) and as such I preferred to keep a longer
buffer (as DNS propagation may take time). As until is used it stops
waiting once the entry is found, the wait time depends on how fast the
DNS entry is found so there is no penalty if it's found sooner.

As the check is then performed from the ACME provider servers, this does
not ensure 100% that when the record is available to you is available
also to them, but in almost all cases this will be true as propagation
to their system will be faster or equal than propagation to your system.
This check has proven very effective for the last 2 years, but YMMV :)

You can obviously tweak retries and delay to suit your network conditions.

Hope it helps!

Best,
Edoardo


-- 
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/417e4163-ce27-98a2-abe5-50c997439246%40arduino.cc.


[ansible-project] Re: How to increase VM OS disk, from template, using ansible vmware guest module

2020-04-08 Thread David Foley
Hi Bhanu,

Are you trying to Deploy From Template but to Increase the Disk , if so a 
simple 

vm_disk:
  disk1:
size_gb: 10
type: thin
datastore: storage001

What is not supported is the decrease the disk size 

-- 
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/c679a37b-3281-4733-86e7-47b0f80ebb60%40googlegroups.com.


[ansible-project] How to increase VM OS disk, from template, using ansible vmware guest module

2020-04-08 Thread Bhanu Prakash
Team,

I am looking for an option 

How to increase VM OS disk, from template, using ansible vmware guest 
module.

Can anyone support 

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8e89ec94-393d-4261-89bb-8c10bc8addc3%40googlegroups.com.


Re: [ansible-project] acme_certificate with *.domain.name

2020-04-08 Thread 'Felix Fontein' via Ansible Project
Hi,

> Thank you for the answer!
> Unfortunately I still can't make acme_certificate to create the
> certificate. I've changed the challenge to dns-01 and
>  taken care of creating the _acme-challenge.domain.name vi REST api
>  but when the last task is run I get:
> "msg": "Authorization for dns:*.domain.name returned invalid:
> CHALLENGE: dns-01 DETAILS: DNS problem: NXDOMAIN looking up TXT for _
> acme-challenge.domain.name - check that a DNS record exists for this
> domain;"
> or
> "msg": "Authorization for dns:domain.name returned invalid:
> CHALLENGE: dns-01 DETAILS: DNS problem: NXDOMAIN looking up TXT for _
> acme-challenge.domain.name - check that a DNS record exists for this
> domain;"
> alternately.
> 
> The DNS record exists * 2 before last task is run and as of the
> ansible output (-vvv) it's the same token.

it looks like the DNS record wasn't there when Let's Encrypt tried to
validate it from (some of) the authoritative name servers for your
domain. You might need to add some waiting to make sure that the DNS
entries propagated among all authoritative name servers for your domain.

Depending on how you set the DNS records, you can ask the API to tell
you when the values propagated (route53 can do that for example), or
you can simply let your playbook/role sleep for some time (I personally
use 30 seconds for my DNS provider; probably less will work as well,
but I never had problems with 30 so I'm sticking to it).

Best,
Felix



> 
> Thank You!
> Patric
> 
> 
> On Sun, Apr 5, 2020 at 9:53 AM 'Felix Fontein' via Ansible Project <
> ansible-project@googlegroups.com> wrote:
> 
> > Hi,
> >
> > you cannot use http-01 challenges for wildcard certificates. You
> > need to use the dns-01 challenge type for that. (This is a policy
> > decision by Let's Encrypt.)
> >
> > How that works depends on how your DNS setup. Ansible needs to be
> > able to create/update the DNS TXT record
> > _acme_challenge.domain.name for this. (If you feel uncomfortable to
> > give Let's Encrypt access to it, you can also use a CNAME record
> > and use https://github.com/joohoi/acme-dns. Haven't tried that with
> > Ansible though.)
> >  
> > > <  
> > https://www.digitalocean.com/community/tutorials/how-to-acquire-a-let-s-encrypt-certificate-using-ansible-on-ubuntu-18-04
> >  
> > >  
> >
> > Interesting, I haven't seen that. One remark: you should change the
> > step which creates the http-01 challenge files slightly by adding
> >
> >   when: item in acme_challenge_your_domain['challenge_data']
> >
> > to it. (Also see the examples in the module docs:
> >
> > https://docs.ansible.com/ansible/latest/modules/acme_certificate_module.html#examples
> > )
> >  
> > > Obviously... You can't name a file with a '*' in it's name.  
> >
> > Actually, you can; you can even have a newline in a filename. But
> > that's never a good idea ;-) And won't help you here, since you
> > can't get wildcard certificates with the http-01 challenge.
> >
> > Cheers,
> > Felix

-- 
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/20200408143219.16fbe4fc%40utsjoki.


Re: [ansible-project] acme_certificate with *.domain.name

2020-04-08 Thread Patric Buskas
Thank you for the answer!
Unfortunately I still can't make acme_certificate to create the certificate.
I've changed the challenge to dns-01 and
 taken care of creating the _acme-challenge.domain.name vi REST api
 but when the last task is run I get:
"msg": "Authorization for dns:*.domain.name returned invalid:  CHALLENGE:
dns-01 DETAILS: DNS problem: NXDOMAIN looking up TXT for _
acme-challenge.domain.name - check that a DNS record exists for this
domain;"
or
"msg": "Authorization for dns:domain.name returned invalid:  CHALLENGE:
dns-01 DETAILS: DNS problem: NXDOMAIN looking up TXT for _
acme-challenge.domain.name - check that a DNS record exists for this
domain;"
alternately.

The DNS record exists * 2 before last task is run and as of the ansible
output (-vvv) it's the same token.

Thank You!
Patric


On Sun, Apr 5, 2020 at 9:53 AM 'Felix Fontein' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> Hi,
>
> you cannot use http-01 challenges for wildcard certificates. You need
> to use the dns-01 challenge type for that. (This is a policy decision
> by Let's Encrypt.)
>
> How that works depends on how your DNS setup. Ansible needs to be able
> to create/update the DNS TXT record _acme_challenge.domain.name for
> this. (If you feel uncomfortable to give Let's Encrypt access to it,
> you can also use a CNAME record and use
> https://github.com/joohoi/acme-dns. Haven't tried that with Ansible
> though.)
>
> > <
> https://www.digitalocean.com/community/tutorials/how-to-acquire-a-let-s-encrypt-certificate-using-ansible-on-ubuntu-18-04
> >
>
> Interesting, I haven't seen that. One remark: you should change the
> step which creates the http-01 challenge files slightly by adding
>
>   when: item in acme_challenge_your_domain['challenge_data']
>
> to it. (Also see the examples in the module docs:
>
> https://docs.ansible.com/ansible/latest/modules/acme_certificate_module.html#examples
> )
>
> > Obviously... You can't name a file with a '*' in it's name.
>
> Actually, you can; you can even have a newline in a filename. But
> that's never a good idea ;-) And won't help you here, since you can't
> get wildcard certificates with the http-01 challenge.
>
> Cheers,
> Felix
>
> --
> 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/20200405095342.2da6eced%40rovaniemi
> .
>

-- 
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/CABG_dsuo27TfqWEXdMJ7LLaYBvb5UEtsMuqjEY2KT23RBMYMrw%40mail.gmail.com.


Re: [ansible-project] Re: Ansible Get vSphere Virtual Machines

2020-04-08 Thread David Foley

>
> Hi Gobi,


I was using that above, but it outputs all information,
I was trying to only output the guest_name with the with_item loop 

-- 
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/6a5bc48a-36ba-48db-8fc0-9e78af9beadd%40googlegroups.com.


Re: [ansible-project] Re: Ansible Get vSphere Virtual Machines

2020-04-08 Thread Gobi
Hi David,
You can do  a loop like this

- debug:
 msg: "{{ item.tags }}"
   with_items:
 - "{{ vm_info.virtual_machines }}"


On Wed, Apr 8, 2020 at 5:16 PM David Foley  wrote:
>>
>> Hi Gobi
>
>
> that outputs the first on the Json List, how would i do a loop ?
>
> i Tried with_items
>
>  - debug:
> msg: "{{ item.tags }}"
>   with_items:
> - "{{ vm_info.virtual_machines.guest_name }}"
>
> --
> 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/9d2f330c-e546-45f0-b8c4-a34b4d0efafd%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/CAKuA%2BXeeE6Mo2L5hERoT%3D%3DydDdOqRSEMq0mGEkAw8PcqOwdz3A%40mail.gmail.com.


[ansible-project] Re: Ansible Get vSphere Virtual Machines

2020-04-08 Thread David Foley

>
> Hi Gobi
>

that outputs the first on the Json List, how would i do a loop ?

i Tried with_items

 - debug:
msg: "{{ item.tags }}"
  with_items:
- "{{ vm_info.virtual_machines.guest_name }}"

-- 
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/9d2f330c-e546-45f0-b8c4-a34b4d0efafd%40googlegroups.com.


Re: [ansible-project] Ansible Get vSphere Virtual Machines

2020-04-08 Thread Gobi
Hi David,

virtual_machines is a list.
This will work:
- debug:
var: vminfo.virtual_machines[0].guest_name

On Wed, 8 Apr, 2020, 4:42 pm David Foley,  wrote:

> Hi All,
>
> Trying to Output only the Virtual Machine Name: but having issues with the
> Json output
>
> ---
> - name: Running Create Virtual Machine Playbook
>   hosts: localhost
>   gather_facts: false
>   connection: local
>   tasks:
>   - name: Get VMs
> vmware_vm_info:
>   validate_certs: no
>   hostname:
>   username:
>   password:
>   vm_type: vm
> delegate_to: localhost
> register: vminfo
>   - debug:
>   var: vminfo.virtual_machines.guest_name
>   - local_action: copy content={{ vminfo.virtual_machines.guest_name
> }} dest=/srv/ansible/vmname.json
>
>
>
>
> I'm currently getting the following Error:
>
>
>
> TASK [debug]
> *
> ok: [localhost] => {
> "vminfo.virtual_machines.guest_name": "VARIABLE IS NOT DEFINED!"
> }
>
> This is the JSON output if i just do a var vminfo
>
> {
>   "failed": false,
>   "virtual_machines":
>   [
> {
>   "guest_name": "",
>   "guest_fullname": "CentOS 7 (64-bit)",
>   "esxi_hostname": "e",
>   "tags": [],
>"cluster": "",
> "vm_network":
> {
>   "":
>   {
> "ipv4": [""],
> "ipv6": []
> },
> "":
> {"ipv4": [""],
>   "ipv6": []},
>   "": {"ipv4": [""], "ipv6": ["f"]}}, "mac_address": [""],
> "attributes": {}, "power_state": "poweredOn", "ip_address": "", "uuid":
> "4212ca75-8a0a-e9dc-95bc-3ee10ea6af11"
> },
>
>
>{
> "guest_name": "", "guest_fullname": "Microsoft Windows 8 (64-bit)",
>
> --
> 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/218fea74-3de0-468f-a9d7-8ab73f826a6a%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/CAKuA%2BXfTGcyOu-H0c%3D2D_v6qv1_oBkAFC9T3coM-qwGJZNXiWw%40mail.gmail.com.


[ansible-project] Ansible Get vSphere Virtual Machines

2020-04-08 Thread David Foley
Hi All,

Trying to Output only the Virtual Machine Name: but having issues with the 
Json output

---
- name: Running Create Virtual Machine Playbook
  hosts: localhost
  gather_facts: false
  connection: local
  tasks:
  - name: Get VMs
vmware_vm_info:
  validate_certs: no
  hostname: 
  username: 
  password: 
  vm_type: vm
delegate_to: localhost
register: vminfo
  - debug:
  var: vminfo.virtual_machines.guest_name
  - local_action: copy content={{ vminfo.virtual_machines.guest_name }} 
dest=/srv/ansible/vmname.json
  



I'm currently getting the following Error:



TASK [debug] 
*
ok: [localhost] => {
"vminfo.virtual_machines.guest_name": "VARIABLE IS NOT DEFINED!"
}

This is the JSON output if i just do a var vminfo

{
  "failed": false, 
  "virtual_machines":
  [
{
  "guest_name": "", 
  "guest_fullname": "CentOS 7 (64-bit)", 
  "esxi_hostname": "e", 
  "tags": [],
   "cluster": "",
"vm_network": 
{
  "": 
  {
"ipv4": [""], 
"ipv6": []
}, 
"": 
{"ipv4": [""], 
  "ipv6": []}, 
  "": {"ipv4": [""], "ipv6": ["f"]}}, "mac_address": [""], 
"attributes": {}, "power_state": "poweredOn", "ip_address": "", "uuid": 
"4212ca75-8a0a-e9dc-95bc-3ee10ea6af11"
},


   {
"guest_name": "", "guest_fullname": "Microsoft Windows 8 (64-bit)", 

-- 
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/218fea74-3de0-468f-a9d7-8ab73f826a6a%40googlegroups.com.


Re: [ansible-project] Latest version of Ansible

2020-04-08 Thread 'Felix Fontein' via Ansible Project
Hi,

> Latest version of ansible is 2.8.9

that's not true. The latest version of Ansible is 2.9.6.
(https://pypi.org/project/ansible/#history)

The 2.9 porting guide is here:
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.9.html

You will need multiple porting guides, depending on with which version
of Ansible you are starting. Every porting guide is describing the
changes between the previous major release and the current one, i.e.
the 2.9 porting guide shows how to upgrade from Ansible 2.8.x to 2.9.

The porting guides for older versions can be obtained by adjusting the
URL:

https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html
https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.7.html
...

About Rahul's original email:

> What is the latest version of Ansible and is it backward compatible ?

The standard deprecation period is 4 versions, so if you are currently
using Ansible 2.5, version 2.9 could have features removed or changed,
while version 2.8 should not (except by accident). There can be other
small changes in behavior; these are all mentioned in the porting
guides, so please read them to be sure.

> Is support for RHEL 8 is there in newer Ansible version ?

RHEL 8 should be supported by all current Ansible versions. CI includes
test runs on RHEL 7 and RHEL 8.

Cheers,
Felix



On Wed, 8 Apr 2020 12:01:16 +0530
"P. Varsha"  wrote:

> Latest version of ansible is 2.8.9
> 
> 
> for more reference you can go with the links it will help you.
> 
> https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html
> 
> 
> https://www.ansible.com/blog/integrating-ansible-and-red-hat-enterprise-linux-8-beta
> 
> 
> On Wed, Apr 8, 2020 at 11:54 AM P. Varsha 
> wrote:
> 
> > Hello Rahul,
> >
> > please find the attachment link of porting guide and latest version
> > of ansible.
> >
> > https://docs.ansible.com/ansible/latest/porting_guides/porting_guides.html
> >
> > https://docs.ansible.com/ansible/2.3/release_and_maintenance.html
> >
> > On Wed, Apr 8, 2020 at 11:49 AM Rahul Kumar 
> > wrote:
> >  
> >> Hello Ansible Gurus,
> >> What is the latest version of Ansible and is it backward
> >> compatible ? Where I can find the porting Guide.
> >> Is support for RHEL 8 is there in newer Ansible version ?
> >>
> >> Rahul

-- 
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/20200408084044.7ae4393c%40rovaniemi.


Re: [ansible-project] Latest version of Ansible

2020-04-08 Thread 'Felix Fontein' via Ansible Project
Hi,

your release_and_maintenance link is seriously outdated (it is for
Ansible 2.3!). Please use

  https://docs.ansible.com/ansible/latest/release_and_maintenance.html

instead.

Cheers,
Felix


On Wed, 8 Apr 2020 11:54:33 +0530
"P. Varsha"  wrote:

> Hello Rahul,
> 
> please find the attachment link of porting guide and latest version of
> ansible.
> 
> https://docs.ansible.com/ansible/latest/porting_guides/porting_guides.html
> https://docs.ansible.com/ansible/2.3/release_and_maintenance.html
> 
> On Wed, Apr 8, 2020 at 11:49 AM Rahul Kumar 
> wrote:
> 
> > Hello Ansible Gurus,
> > What is the latest version of Ansible and is it backward compatible
> > ? Where I can find the porting Guide.
> > Is support for RHEL 8 is there in newer Ansible version ?
> >
> > Rahul
> >
> > --
> > 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/CAGH8rEzzft0gc49yCe5JyoSynM1w8eEdB_E4%2BEAHaXgB%3D1dvgQ%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/20200408083218.04528abc%40rovaniemi.


Re: [ansible-project] Latest version of Ansible

2020-04-08 Thread P. Varsha
Latest version of ansible is 2.8.9


for more reference you can go with the links it will help you.

https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html


https://www.ansible.com/blog/integrating-ansible-and-red-hat-enterprise-linux-8-beta


On Wed, Apr 8, 2020 at 11:54 AM P. Varsha  wrote:

> Hello Rahul,
>
> please find the attachment link of porting guide and latest version of
> ansible.
>
> https://docs.ansible.com/ansible/latest/porting_guides/porting_guides.html
>
> https://docs.ansible.com/ansible/2.3/release_and_maintenance.html
>
> On Wed, Apr 8, 2020 at 11:49 AM Rahul Kumar 
> wrote:
>
>> Hello Ansible Gurus,
>> What is the latest version of Ansible and is it backward compatible ?
>> Where I can find the porting Guide.
>> Is support for RHEL 8 is there in newer Ansible version ?
>>
>> Rahul
>>
>> --
>> 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/CAGH8rEzzft0gc49yCe5JyoSynM1w8eEdB_E4%2BEAHaXgB%3D1dvgQ%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/CAA3T03JwHS9EyMCLGT1JPtFygLBDFAqQ2%2BYqKRKfOn9UiGTkRw%40mail.gmail.com.


Re: [ansible-project] Latest version of Ansible

2020-04-08 Thread P. Varsha
Hello Rahul,

please find the attachment link of porting guide and latest version of
ansible.

https://docs.ansible.com/ansible/latest/porting_guides/porting_guides.html
https://docs.ansible.com/ansible/2.3/release_and_maintenance.html

On Wed, Apr 8, 2020 at 11:49 AM Rahul Kumar  wrote:

> Hello Ansible Gurus,
> What is the latest version of Ansible and is it backward compatible ?
> Where I can find the porting Guide.
> Is support for RHEL 8 is there in newer Ansible version ?
>
> Rahul
>
> --
> 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/CAGH8rEzzft0gc49yCe5JyoSynM1w8eEdB_E4%2BEAHaXgB%3D1dvgQ%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/CAA3T03JgENh_81cv2n4rdk7gJAeYGKoAffN%2B-gakZffxjvzNOQ%40mail.gmail.com.


[ansible-project] Latest version of Ansible

2020-04-08 Thread Rahul Kumar
Hello Ansible Gurus,
What is the latest version of Ansible and is it backward compatible ?
Where I can find the porting Guide.
Is support for RHEL 8 is there in newer Ansible version ?

Rahul

-- 
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/CAGH8rEzzft0gc49yCe5JyoSynM1w8eEdB_E4%2BEAHaXgB%3D1dvgQ%40mail.gmail.com.