Re: [ansible-project] Cannot use signature-based authentication because pyopenssl is not available

2019-09-24 Thread Vladimir Botka
On Wed, 25 Sep 2019 05:58:08 +0200
Dick Visser  wrote:
> Your ansible is using python2.
> So either install ansible using python3, or install pyopenssl for python2
> (if that’s possible at all, can’t tell from here).
> 
> On Wed, 25 Sep 2019 at 01:23, Antien Ho  wrote:
> > environment: windows 10 Ubuntu 18.04 LTS.
> > python version as standard:
> > ansible-playbook 2.8.5
> >   python version = 2.7.15+ (default, Jul  9 2019, 16:51:35) [GCC 7.4.0]
> > I always getting the topic error. pyopenssl is not available.
> > I did  install the pyopenssl with "pip3 install pyopenssl"..as latest

Install PyOpenSSL on the remote host. Quoting from the doc:

  PyOpenSSL is "needed on the host that executes this module"
  
https://docs.ansible.com/ansible/latest/modules/openssl_certificate_module.html

What Python shall be used on the remote host depends how the packages have
been built and what packages were installed. For example FreeBSD works fine
with both

  py27-openssl-18.0.0Python interface to the OpenSSL library
  py36-openssl-17.5.0_1  Python interface to the OpenSSL library

If you have to use pip to install the packages make sure the paths are set
properly and Ansible is able to use it.

Cheers,

-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/20190925062859.12b921b1%40gmail.com.


pgp2bmAuEVIEp.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Cannot use signature-based authentication because pyopenssl is not available

2019-09-24 Thread Dick Visser
Your ansible is using python2.
So either install ansible using python3, or install pyopenssl for python2
(if that’s possible at all, can’t tell from here).

Dick

On Wed, 25 Sep 2019 at 01:23, Antien Ho  wrote:

> environment: windows 10 Ubuntu 18.04 LTS.
> python version as standard:
>
> ansible-playbook 2.8.5
>   config file = /etc/ansible/ansible.cfg
>   configured module search path =
> [u'/home/antienho/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/dist-packages/ansible
>   executable location = /usr/bin/ansible-playbook
>   python version = 2.7.15+ (default, Jul  9 2019, 16:51:35) [GCC 7.4.0]
> Using /etc/ansible/ansible.cfg as config file
>
> in a ACI environment, and installed the openssl cert key with .pem and .key
> by following
> openssl req -new -newkey rsa:1024 -days 36500 -nodes -x509 -keyout
> antien.key -out antien.pem -subj '/CN=Antien/O=conreslab/C=US'.
> the .pem is properly installed in ACI.
> however when run the simple yml file.
> I always getting the topic error. pyopenssl is not available.
>
> I did  install the pyopenssl with "pip3 install pyopenssl"..as latest
> pyopenssl 19.0.0 version..see below:
>
> pip3 install pyopenssl
> Collecting pyopenssl
>   Using cached
> https://files.pythonhosted.org/packages/01/c8/ceb170d81bd3941cbeb9940fc6cc2ef2ca4288d0ca8929ea4db5905d904d/pyOpenSSL-19.0.0-py2.py3-none-any.whl
> Collecting six>=1.5.2 (from pyopenssl)
>   Using cached
> https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
> Collecting cryptography>=2.3 (from pyopenssl)
>   Using cached
> https://files.pythonhosted.org/packages/97/18/c6557f63a6abde34707196fb2cad1c6dc0dbff25a200d5044922496668a4/cryptography-2.7-cp34-abi3-manylinux1_x86_64.whl
> Collecting cffi!=1.11.3,>=1.8 (from cryptography>=2.3->pyopenssl)
>   Using cached
> https://files.pythonhosted.org/packages/5f/bf/6aa1925384c23ffeb579e97a5569eb9abce41b6310b329352b8252cee1c3/cffi-1.12.3-cp36-cp36m-manylinux1_x86_64.whl
> Collecting asn1crypto>=0.21.0 (from cryptography>=2.3->pyopenssl)
>   Using cached
> https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl
> Collecting pycparser (from
> cffi!=1.11.3,>=1.8->cryptography>=2.3->pyopenssl)
> Installing collected packages: six, pycparser, cffi, asn1crypto,
> cryptography, pyopenssl
> Successfully installed asn1crypto-0.24.0 cffi-1.12.3 cryptography-2.7
> pycparser-2.19 pyopenssl-19.0.0 six-1.12.0
>
>
> I will post any addition information if required.  Any suggestions are
> appreciated.
>
>
> Thanks
>
> Antien
>
>
> --
> 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/fa858c8b-c931-4795-93b4-5f7220ab1183%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/CAL8fbwMpEk%3D%2BRSmAv81jLeUOiGXzocjoBftsw2ZsBEQX_HpY4A%40mail.gmail.com.


[ansible-project] Cannot use signature-based authentication because pyopenssl is not available

2019-09-24 Thread Antien Ho
environment: windows 10 Ubuntu 18.04 LTS.
python version as standard: 

ansible-playbook 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
[u'/home/antienho/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15+ (default, Jul  9 2019, 16:51:35) [GCC 7.4.0]
Using /etc/ansible/ansible.cfg as config file

in a ACI environment, and installed the openssl cert key with .pem and .key
by following 
openssl req -new -newkey rsa:1024 -days 36500 -nodes -x509 -keyout 
antien.key -out antien.pem -subj '/CN=Antien/O=conreslab/C=US'.
the .pem is properly installed in ACI.
however when run the simple yml file. 
I always getting the topic error. pyopenssl is not available.

I did  install the pyopenssl with "pip3 install pyopenssl"..as latest 
pyopenssl 19.0.0 version..see below:

pip3 install pyopenssl
Collecting pyopenssl
  Using cached 
https://files.pythonhosted.org/packages/01/c8/ceb170d81bd3941cbeb9940fc6cc2ef2ca4288d0ca8929ea4db5905d904d/pyOpenSSL-19.0.0-py2.py3-none-any.whl
Collecting six>=1.5.2 (from pyopenssl)
  Using cached 
https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting cryptography>=2.3 (from pyopenssl)
  Using cached 
https://files.pythonhosted.org/packages/97/18/c6557f63a6abde34707196fb2cad1c6dc0dbff25a200d5044922496668a4/cryptography-2.7-cp34-abi3-manylinux1_x86_64.whl
Collecting cffi!=1.11.3,>=1.8 (from cryptography>=2.3->pyopenssl)
  Using cached 
https://files.pythonhosted.org/packages/5f/bf/6aa1925384c23ffeb579e97a5569eb9abce41b6310b329352b8252cee1c3/cffi-1.12.3-cp36-cp36m-manylinux1_x86_64.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=2.3->pyopenssl)
  Using cached 
https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl
Collecting pycparser (from cffi!=1.11.3,>=1.8->cryptography>=2.3->pyopenssl)
Installing collected packages: six, pycparser, cffi, asn1crypto, 
cryptography, pyopenssl
Successfully installed asn1crypto-0.24.0 cffi-1.12.3 cryptography-2.7 
pycparser-2.19 pyopenssl-19.0.0 six-1.12.0


I will post any addition information if required.  Any suggestions are 
appreciated. 


Thanks

Antien 
 

-- 
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/fa858c8b-c931-4795-93b4-5f7220ab1183%40googlegroups.com.


Re: [ansible-project] traversing directory structure

2019-09-24 Thread Vladimir Botka
On Tue, 24 Sep 2019 12:57:35 -0700 (PDT)
Gregory Edigarov  wrote:

> hello,
> 
> let's look at the following structure:
> var/
>   ssh/
>user1
>user2
>user3
> 
>   hosts/
>host1/
> user1
> user3
>
>   host2/
>user2
>user3
> 
> under /var/ssh there are public keys for users
> 
> files under host1,host2 catalog are empty files just pointing ansible on 
> which host which user must be added

Short answer: Below is the playbook that you probably want.

- hosts: localhost
  tasks:
  - name: get hosts from hosts directory
command: ls -1 var/hosts
register: ssh_hosts
  - name: create my_group
add_host:
  hostname: "{{ item }}"
  groups:
- 'my_group'
loop: "{{ ssh_hosts.stdout_lines }}"

- hosts: my_group
  become: true
  tasks:
- name: get usernames
  command: "ls -1 var/hosts/{{ inventory_hostname }}"
  register: usernames_host
- name: add users
  user:
name: "{{ item }}"
shell: /bin/bash
group: sudo
  loop: "{{ usernames_host.stdout_lines }}"
- name: add user keys
  authorized_key:
user: "{{ item }}"
key: "{{ lookup('file', 'var/ssh/' ~ item ) }}"
  loop: "{{ usernames_host.stdout_lines }}"

Details:

Create a group "my_group" instead of variable "ssh_hosts_fact"

  - name: create my_group
add_host:
  hostname: "{{ item }}"
  groups:
- 'my_group'
loop: "{{ ssh_hosts.stdout_lines }}"
 
>   - name: set ssh_hosts_fact
> set_fact:
>   ssh_hosts_fact: "{{ ssh_hosts.stdout_lines }}"

Start another play with the group "my_group" instead of the "include". No
delegation and loop_control is needed.

- hosts: my_group
  become: true
  tasks:

>   - name: include subtasks
> include: ssh_body.yml host="{{ item }}"
> with_items:
>   - "{{ ssh_hosts_fact }}"

Cheers,

-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/20190925001700.48a633ad%40gmail.com.


pgp_eIH49dcy7.pgp
Description: OpenPGP digital signature


[ansible-project] Re: Loading variables with data from REST

2019-09-24 Thread Paul Hoffman
Thanks Nick,  
That worked great to give me back the value itself.


On Tuesday, September 24, 2019 at 2:10:46 PM UTC-5, Nick Schendel wrote:
>
> I am working on some playbooks right now using the URI module and doing 
> what you describe. If you register the output of the task, you can call the 
> response contents with output.json.keyname.  Where output is the name you 
> used in the register. So as an example:
>
>   - name: get some value via URI call
> uri:
> url: https://{{ server_hostname }}/api/somepath
> register: uri_output
>
> Now in later plays you can use uri_output.json.keyx, or uri_output.somekey 
> for values returned in the response body itself.  Some of the stuff I am 
> doing will return a json aray, and for those I am using 
> uri_output.json.data[0].key to get at what I need.  Now I just need to 
> figure out how to query the returned array to match a particular value.
>
> I was also able to set a specific value to a variable with set_fact:
>
> - name: set variable for target_vm_id
> set_fact:
>   target_vm_id: "{{ vminfo.json.data[0].id }}"
>
>
> On Tuesday, September 24, 2019 at 1:25:45 PM UTC-5, Paul Hoffman wrote:
>>
>> I'd like to leverage systems with an API to provide variables to 
>> playbooks running on the controller.
>> Something similar to a dynamic inventory script loading from an external 
>> system.
>>
>> For example with a curl command and can get the exact contents I need.  
>> IE: {"myVariable":"myValue"}  or yaml format:
>> myVariable: myValue
>>
>> I've looked at the uri module and it looks promising.  The values 
>> returned by the GET call are embedded in the 
>> returned contents along with many other API variables.
>>
>> The idea being when I need a value that changes frequently or shouldn't 
>> be included in static playbooks I call the 
>> external system that has the master value and load it.
>> I'd prefer not pulling the data into a variable file first.  That would 
>> avoid file management issues.
>>
>> I'm not too familiar with jinja2 but perhaps there's a way to take the 
>> output from URI and parse out the values.
>> I'm sure there is a way to do this that I haven't come across yet.
>>
>> If anyone has already solved this point me in the right direction.
>> v/r
>>
>>

-- 
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/436f2df8-4761-4316-b67c-70bf10bcf445%40googlegroups.com.


[ansible-project] traversing directory structure

2019-09-24 Thread Gregory Edigarov
hello,

let's look at the following structure:
var/
  ssh/
   user1
   user2
   user3

  hosts/
   host1/
user1
user3
   
  host2/
   user2
   user3

under /var/ssh there are public keys for users

files under host1,host2 catalog are empty files just pointing ansible on 
which host which user must be added

i did the task by reading the hosts/ one level into an array, then looping 
over it 
like:
   
hosts: localhost
  tasks:
  - name: get hosts from hosts directory
command: ls -1 var/hosts
register: ssh_hosts

  - name: set ssh_hosts_fact
set_fact:
  ssh_hosts_fact: "{{ ssh_hosts.stdout_lines }}"

  - name: include subtasks
include: ssh_body.yml host="{{ item }}"
with_items:
  - "{{ ssh_hosts_fact }}"

then 
in included file:

- name: get usernames for host
  command: ls -1 var/hosts/{{ host }}
  register: usernames_host

- name: add users onto host 
  user: 
name: "{{ user_item }}"
shell: /bin/bash
group: sudo
  with_items: 
"{{ usernames_host.stdout_lines }}"
  delegate_to: "{{ host }}" 
  loop_control: 
loop_var: user_item
  become: true

- name: add user keys
  authorized_key:
user: "{{ user_item }}"
key: "{{ lookup('file', 'var/ssh/{{ user_item }}' ) }}"
  with_items: 
"{{ usernames_host.stdout_lines }}"
  delegate_to: "{{ host }}"
  loop_control: 
loop_var: user_item
  become: true


it works, but I think there is more effective way of doing thing, at least 
with no includes
any suggestions?

thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/09c0cd0c-95c6-445b-967e-512157de21f6%40googlegroups.com.


Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Rakesh Parida
Hi Kai,

I could do achieve what i intended. I made the following changes using 
Jinja format and my issue solved. 
Thanks for the help. Th echanges i made was:
In the Instance id section i used the foloing formula and it worked like a 
charm.

- name: Set fact for Instance id from Tenant ID
  delegate_to: localhost
  set_fact:
id_list: "{% for item in instid.results %}
{{ item.stdout_lines[0].split()[0] }}
{% endfor %}"

- name: Set fact for Desired Instance ids
  set_fact:
 desired_instid: "{{ id_list.split() }}"

On Tuesday, September 24, 2019 at 11:33:16 PM UTC+5:30, Karl Auer wrote:
>
> Post the *complete* output of
>
> - debug:
>var: instid
>
> Posting snippets is useless.
>
>
> On Wed, Sep 25, 2019 at 3:39 AM Rakesh Parida  > wrote:
>
>> There are 11 items , i will paste the out put of one item, all others are 
>> similar, or this mail will be lengthy. SO pasting the out put of one item.
>>
>>  "_ansible_delegated_vars": {
>> "ansible_delegated_host": "localhost", 
>> "ansible_host": "localhost"
>> }, 
>> "_ansible_ignore_errors": null, 
>> "_ansible_item_label": "TOMICS2", 
>> "_ansible_item_result": true, 
>> "_ansible_no_log": false, 
>> "_ansible_parsed": true, 
>> "changed": true, 
>> "cmd": "openstack server list --all-projects 
>> --project \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3 { print $2, $4 
>> }' | grep -i \"TOMICS2\"", 
>> "delta": "0:00:02.312475", 
>> "end": "2019-09-24 09:15:48.113526", 
>> "failed": false, 
>> "invocation": {
>> "module_args": {
>> "_raw_params": "openstack server list 
>> --all-projects --project \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3 
>> { print $2, $4 }' | grep -i \"TOMICS2\"", 
>> "_uses_shell": true, 
>> "argv": null, 
>> "chdir": null, 
>> "creates": null, 
>> "executable": null, 
>> "removes": null, 
>> "stdin": null, 
>> "warn": true
>> }
>> }, 
>> "item": "TOMICS2", 
>> "rc": 0, 
>> "start": "2019-09-24 09:15:45.801051", 
>> "stderr": "", 
>> "stderr_lines": [], 
>> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804 
>> TOMICS2", 
>>   *  "stdout_lines": [*
>> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2"*
>> ]
>> }, 
>>
>>
>>
>> On Tuesday, September 24, 2019 at 10:55:00 PM UTC+5:30, Karl Auer wrote:
>>>
>>> What is the *complete* output from a debug of instid?
>>>
>>>
>>> Regards, K.
>>>
>>>
>>> On Wed, Sep 25, 2019 at 3:06 AM Rakesh Parida  
>>> wrote:
>>>
 Hi,

 I have  playbook to retrieve the Instance id of Openstack nodes.Now 
 everything works fine but the resgitered value for instid.stdout_lines 
 gets 
 an undefined error.
 *The error was: 'dict object' has no attribute 'stdout_lines'* .. but 
 when i debug the complete registered variable instid i see stdout_lines. 
 but why its failing when i debug it using instid.stdout_lines

  "item": "TOMCS2", 
 "rc": 0, 
 "start": "2019-09-24 09:15:45.801051", 
 "stderr": "", 
 "stderr_lines": [], 
 "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804 
 TOMICS2", 
 *"stdout_lines": [*
 *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*


 - hosts: nodes[0]
   gather_facts: false
   tasks:
 - name: Collect  Hostnames
   set_fact:
  host_lists: "{{ 
 hostvars[inventory_hostname]['groups']['nodes'] }}"

 - name: Create Hostname as per the Name in openstack names
   set_fact:
  fact: '{{ (["TOM"] * 
 host_lists|length)|zip(host_lists)|map("join")|list}}'

 - name: Debug the required list
   debug:
 msg: "{{ fact }}"


 - hosts: 127.0.0.1
   gather_facts: false
   tasks:
 - name: Retrieve tenantID
   shell: openstack project list | awk '/ TOM / { print $2 }'
   register: tenantid

  - name: Retrieve instance id from tenant
shell: openstack server list --all-projects --project "{{ 
 tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
   

Re: [ansible-project] Connection via Citrix

2019-09-24 Thread goforawalktwice
I've been setting up Citrix client applications (VDA virtual desktop agent) via 
ansible and having Citrix admin people publish. VDA runs on a server that is 
like any other server ... Winrm etc.

-- 
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/e8f30cf7-cb7d-48e4-a235-d4d3362a548a%40googlegroups.com.


[ansible-project] Re: traversing directory structure

2019-09-24 Thread Gregory Edigarov
sorry, slip of fingers, will do another post

On Tuesday, September 24, 2019 at 10:34:43 PM UTC+3, Gregory Edigarov wrote:
>
> hello
>
> let's look at example: directory structure
>
> vars/
> ssh/
> user1
>
>
>
>

-- 
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/43546788-911d-448c-a2e8-716295a72757%40googlegroups.com.


[ansible-project] traversing directory structure

2019-09-24 Thread Gregory Edigarov
hello

let's look at example: directory structure

vars/
ssh/
user1



-- 
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/2b0dada7-99fa-4435-9cc7-91d503b05ea6%40googlegroups.com.


[ansible-project] Re: Loading variables with data from REST

2019-09-24 Thread Nick Schendel
I am working on some playbooks right now using the URI module and doing 
what you describe. If you register the output of the task, you can call the 
response contents with output.json.keyname.  Where output is the name you 
used in the register. So as an example:

  - name: get some value via URI call
uri:
url: https://{{ server_hostname }}/api/somepath
register: uri_output

Now in later plays you can use uri_output.json.keyx, or uri_output.somekey 
for values returned in the response body itself.  Some of the stuff I am 
doing will return a json aray, and for those I am using 
uri_output.json.data[0].key to get at what I need.  Now I just need to 
figure out how to query the returned array to match a particular value.

I was also able to set a specific value to a variable with set_fact:

- name: set variable for target_vm_id
set_fact:
  target_vm_id: "{{ vminfo.json.data[0].id }}"


On Tuesday, September 24, 2019 at 1:25:45 PM UTC-5, Paul Hoffman wrote:
>
> I'd like to leverage systems with an API to provide variables to playbooks 
> running on the controller.
> Something similar to a dynamic inventory script loading from an external 
> system.
>
> For example with a curl command and can get the exact contents I need.  
> IE: {"myVariable":"myValue"}  or yaml format:
> myVariable: myValue
>
> I've looked at the uri module and it looks promising.  The values returned 
> by the GET call are embedded in the 
> returned contents along with many other API variables.
>
> The idea being when I need a value that changes frequently or shouldn't be 
> included in static playbooks I call the 
> external system that has the master value and load it.
> I'd prefer not pulling the data into a variable file first.  That would 
> avoid file management issues.
>
> I'm not too familiar with jinja2 but perhaps there's a way to take the 
> output from URI and parse out the values.
> I'm sure there is a way to do this that I haven't come across yet.
>
> If anyone has already solved this point me in the right direction.
> v/r
>
>

-- 
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/e59bab51-b707-40fe-8df4-2efc7ef946d5%40googlegroups.com.


[ansible-project] VMware Dynamic Inventory Plugin Performance Configuration

2019-09-24 Thread Scott MacDonald
Just setup the VMware Dynamic Inventory Plugin, as documented 
at 
https://docs.ansible.com/ansible/latest/scenario_guides/vmware_scenarios/vmware_inventory.html

It was easy enough  to follow and get it to "functionally" work, but its  
performance  returning inventory from  my tiny little 143 VM cluster is  
awful( especially given I'm, generally, only concerned with a sliver  of 
that total inventory,  and my specific playbook I'm working with  is only 
actually targeting a single vm)   

The  plugin docs lack any info on performance tuning, and i found nothing 
but noise  out there in the google-sphere.. nevertheless,  I'm hoping 
there is some type of  performance configuration that may help.

Anybody know if the VMware Dynamic Inventory Plugin supports any 
performance, and if.so, how to actually configure it?

-- 
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/5fd9da24-33af-453e-8708-82b55dbcb3a2%40googlegroups.com.


Re: [ansible-project] Loading variables with data from REST

2019-09-24 Thread Mark Anthony Garcia
I've used this using uri module, fust to get the cookies and use the cookie
to run several api queries. I used jinja to template the data for API PUT
and POST but it's a bit tricky with the formating.

I'm not in front of my pc but perhaps first thing tomorrow I'll share what
I have.

Mark Garcia

On Tue, Sep 24, 2019, 8:25 PM Paul Hoffman 
wrote:

> I'd like to leverage systems with an API to provide variables to playbooks
> running on the controller.
> Something similar to a dynamic inventory script loading from an external
> system.
>
> For example with a curl command and can get the exact contents I need.
> IE: {"myVariable":"myValue"}  or yaml format:
> myVariable: myValue
>
> I've looked at the uri module and it looks promising.  The values returned
> by the GET call are embedded in the
> returned contents along with many other API variables.
>
> The idea being when I need a value that changes frequently or shouldn't be
> included in static playbooks I call the
> external system that has the master value and load it.
> I'd prefer not pulling the data into a variable file first.  That would
> avoid file management issues.
>
> I'm not too familiar with jinja2 but perhaps there's a way to take the
> output from URI and parse out the values.
> I'm sure there is a way to do this that I haven't come across yet.
>
> If anyone has already solved this point me in the right direction.
> v/r
>
> --
> 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/cd69ac14-8216-441d-a413-6f4e42804892%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/CAGFwMxqC-Ffd3fPEHJYCykRgVW7d5iK3LOhKNOcDZBLCu6O8Aw%40mail.gmail.com.


[ansible-project] Loading variables with data from REST

2019-09-24 Thread Paul Hoffman
I'd like to leverage systems with an API to provide variables to playbooks 
running on the controller.
Something similar to a dynamic inventory script loading from an external 
system.

For example with a curl command and can get the exact contents I need.  IE: 
{"myVariable":"myValue"}  or yaml format:
myVariable: myValue

I've looked at the uri module and it looks promising.  The values returned 
by the GET call are embedded in the 
returned contents along with many other API variables.

The idea being when I need a value that changes frequently or shouldn't be 
included in static playbooks I call the 
external system that has the master value and load it.
I'd prefer not pulling the data into a variable file first.  That would 
avoid file management issues.

I'm not too familiar with jinja2 but perhaps there's a way to take the 
output from URI and parse out the values.
I'm sure there is a way to do this that I haven't come across yet.

If anyone has already solved this point me in the right direction.
v/r

-- 
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/cd69ac14-8216-441d-a413-6f4e42804892%40googlegroups.com.


Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Karl Auer
Post the *complete* output of

- debug:
   var: instid

Posting snippets is useless.


On Wed, Sep 25, 2019 at 3:39 AM Rakesh Parida 
wrote:

> There are 11 items , i will paste the out put of one item, all others are
> similar, or this mail will be lengthy. SO pasting the out put of one item.
>
>  "_ansible_delegated_vars": {
> "ansible_delegated_host": "localhost",
> "ansible_host": "localhost"
> },
> "_ansible_ignore_errors": null,
> "_ansible_item_label": "TOMICS2",
> "_ansible_item_result": true,
> "_ansible_no_log": false,
> "_ansible_parsed": true,
> "changed": true,
> "cmd": "openstack server list --all-projects --project
> \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3 { print $2, $4 }' | grep
> -i \"TOMICS2\"",
> "delta": "0:00:02.312475",
> "end": "2019-09-24 09:15:48.113526",
> "failed": false,
> "invocation": {
> "module_args": {
> "_raw_params": "openstack server list
> --all-projects --project \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3
> { print $2, $4 }' | grep -i \"TOMICS2\"",
> "_uses_shell": true,
> "argv": null,
> "chdir": null,
> "creates": null,
> "executable": null,
> "removes": null,
> "stdin": null,
> "warn": true
> }
> },
> "item": "TOMICS2",
> "rc": 0,
> "start": "2019-09-24 09:15:45.801051",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804
> TOMICS2",
>   *  "stdout_lines": [*
> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2"*
> ]
> },
>
>
>
> On Tuesday, September 24, 2019 at 10:55:00 PM UTC+5:30, Karl Auer wrote:
>>
>> What is the *complete* output from a debug of instid?
>>
>>
>> Regards, K.
>>
>>
>> On Wed, Sep 25, 2019 at 3:06 AM Rakesh Parida 
>> wrote:
>>
>>> Hi,
>>>
>>> I have  playbook to retrieve the Instance id of Openstack nodes.Now
>>> everything works fine but the resgitered value for instid.stdout_lines gets
>>> an undefined error.
>>> *The error was: 'dict object' has no attribute 'stdout_lines'* .. but
>>> when i debug the complete registered variable instid i see stdout_lines.
>>> but why its failing when i debug it using instid.stdout_lines
>>>
>>>  "item": "TOMCS2",
>>> "rc": 0,
>>> "start": "2019-09-24 09:15:45.801051",
>>> "stderr": "",
>>> "stderr_lines": [],
>>> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804
>>> TOMICS2",
>>> *"stdout_lines": [*
>>> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*
>>>
>>>
>>> - hosts: nodes[0]
>>>   gather_facts: false
>>>   tasks:
>>> - name: Collect  Hostnames
>>>   set_fact:
>>>  host_lists: "{{ hostvars[inventory_hostname]['groups']['nodes']
>>> }}"
>>>
>>> - name: Create Hostname as per the Name in openstack names
>>>   set_fact:
>>>  fact: '{{ (["TOM"] *
>>> host_lists|length)|zip(host_lists)|map("join")|list}}'
>>>
>>> - name: Debug the required list
>>>   debug:
>>> msg: "{{ fact }}"
>>>
>>>
>>> - hosts: 127.0.0.1
>>>   gather_facts: false
>>>   tasks:
>>> - name: Retrieve tenantID
>>>   shell: openstack project list | awk '/ TOM / { print $2 }'
>>>   register: tenantid
>>>
>>>  - name: Retrieve instance id from tenant
>>>shell: openstack server list --all-projects --project "{{
>>> tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
>>>with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}"
>>>register: instid
>>>
>>> - name: Debug Instance id and Tennat id
>>>   delegate_to: localhost
>>>   debug:
>>> msg:
>>>  - "Tenant ID:"
>>>  - "{{ tenantid.stdout }}"
>>>  - "==="
>>>  - "Instance ID of the VMs in TOM
>>>  - "{{ instid.stdout_lines}}"
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/cc57f323-5d44-4b9b-97e9-ccc1e9f19542%40googlegroups.com
>>> 

Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Kai Stian Olstad
On 24.09.2019 19:48, Rakesh Parida wrote:
> Hi Kai,
> 
> I had already tried it it gives me o/p as same as :
> debug:
>  msg: {{ instid }}
> 
> Both the o/ps are similar.
> 
> Now  i want the stdout_lines for each item as my desired o/p
> something like:
> e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2
> 7865dvgsf-17f3-4b80-a935-03164211a804 TOMICS1
> abc12345g-17f3-4b80-a935-03164211a804 TOMIAS2

As I wrote instid contains a results which is a list so you need to loop over 
it to get the individual results.

- debug: msg="{{ item.stdout }}"
  with_items: "{{ instid.results }}"

-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/94242458-ca59-cb83-ad99-27b7ba3a8fa6%40olstad.com.


Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Rakesh Parida
Hi Kai,

I had already tried it it gives me o/p as same as :
debug:
msg: {{ instid }}

Both the o/ps are similar.

Now  i want the stdout_lines for each item as my desired o/p
something like:
e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2
7865dvgsf-17f3-4b80-a935-03164211a804 TOMICS1
abc12345g-17f3-4b80-a935-03164211a804 TOMIAS2

On Tuesday, September 24, 2019 at 11:05:06 PM UTC+5:30, Kai Stian Olstad 
wrote:
>
> On 24.09.2019 19:06, Rakesh Parida wrote: 
> >   - name: Retrieve instance id from tenant 
> > shell: openstack server list --all-projects --project "{{ 
> > tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item 
> }}" 
> > with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}" 
> > register: instid 
> > 
> >  - name: Debug Instance id and Tennat id 
> >delegate_to: localhost 
> >debug: 
> >  msg: 
> >   - "Tenant ID:" 
> >   - "{{ tenantid.stdout }}" 
> >   - "===" 
> >   - "Instance ID of the VMs in TOM 
> >   - "{{ instid.stdout_lines}}" 
>
> When using register with with_items/loop you'll have instid.results which 
> is a list where each item contain the output for each command. 
>
> When you get errors like this always run a 
>   - debug: var=instid 
>
> -- 
> Kai Stian Olstad 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/50aaf43a-f2b3-48a0-bff5-651e8fd78b67%40googlegroups.com.


Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Rakesh Parida
There are 11 items , i will paste the out put of one item, all others are 
similar, or this mail will be lengthy. SO pasting the out put of one item.

 "_ansible_delegated_vars": {
"ansible_delegated_host": "localhost", 
"ansible_host": "localhost"
}, 
"_ansible_ignore_errors": null, 
"_ansible_item_label": "TOMICS2", 
"_ansible_item_result": true, 
"_ansible_no_log": false, 
"_ansible_parsed": true, 
"changed": true, 
"cmd": "openstack server list --all-projects --project 
\"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3 { print $2, $4 }' | grep 
-i \"TOMICS2\"", 
"delta": "0:00:02.312475", 
"end": "2019-09-24 09:15:48.113526", 
"failed": false, 
"invocation": {
"module_args": {
"_raw_params": "openstack server list 
--all-projects --project \"ca257bcbf01745aba61edd9699cd4902\" | awk 'NR > 3 
{ print $2, $4 }' | grep -i \"TOMICS2\"", 
"_uses_shell": true, 
"argv": null, 
"chdir": null, 
"creates": null, 
"executable": null, 
"removes": null, 
"stdin": null, 
"warn": true
}
}, 
"item": "TOMICS2", 
"rc": 0, 
"start": "2019-09-24 09:15:45.801051", 
"stderr": "", 
"stderr_lines": [], 
"stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804 
TOMICS2", 
  *  "stdout_lines": [*
*"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMICS2"*
]
}, 



On Tuesday, September 24, 2019 at 10:55:00 PM UTC+5:30, Karl Auer wrote:
>
> What is the *complete* output from a debug of instid?
>
>
> Regards, K.
>
>
> On Wed, Sep 25, 2019 at 3:06 AM Rakesh Parida  > wrote:
>
>> Hi,
>>
>> I have  playbook to retrieve the Instance id of Openstack nodes.Now 
>> everything works fine but the resgitered value for instid.stdout_lines gets 
>> an undefined error.
>> *The error was: 'dict object' has no attribute 'stdout_lines'* .. but 
>> when i debug the complete registered variable instid i see stdout_lines. 
>> but why its failing when i debug it using instid.stdout_lines
>>
>>  "item": "TOMCS2", 
>> "rc": 0, 
>> "start": "2019-09-24 09:15:45.801051", 
>> "stderr": "", 
>> "stderr_lines": [], 
>> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804 
>> TOMICS2", 
>> *"stdout_lines": [*
>> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*
>>
>>
>> - hosts: nodes[0]
>>   gather_facts: false
>>   tasks:
>> - name: Collect  Hostnames
>>   set_fact:
>>  host_lists: "{{ hostvars[inventory_hostname]['groups']['nodes'] 
>> }}"
>>
>> - name: Create Hostname as per the Name in openstack names
>>   set_fact:
>>  fact: '{{ (["TOM"] * 
>> host_lists|length)|zip(host_lists)|map("join")|list}}'
>>
>> - name: Debug the required list
>>   debug:
>> msg: "{{ fact }}"
>>
>>
>> - hosts: 127.0.0.1
>>   gather_facts: false
>>   tasks:
>> - name: Retrieve tenantID
>>   shell: openstack project list | awk '/ TOM / { print $2 }'
>>   register: tenantid
>>
>>  - name: Retrieve instance id from tenant
>>shell: openstack server list --all-projects --project "{{ 
>> tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
>>with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}"
>>register: instid
>>
>> - name: Debug Instance id and Tennat id
>>   delegate_to: localhost
>>   debug:
>> msg:
>>  - "Tenant ID:"
>>  - "{{ tenantid.stdout }}"
>>  - "==="
>>  - "Instance ID of the VMs in TOM
>>  - "{{ instid.stdout_lines}}"
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/cc57f323-5d44-4b9b-97e9-ccc1e9f19542%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Karl Auer
>
> Email  : ka...@2pisoftware.com 
> Website: http://2pisoftware.com
>
> GPG/PGP : 301B 1F4E 624D AD99 242C 

Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Kai Stian Olstad
On 24.09.2019 19:06, Rakesh Parida wrote:
>   - name: Retrieve instance id from tenant
> shell: openstack server list --all-projects --project "{{
> tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
> with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}"
> register: instid
> 
>  - name: Debug Instance id and Tennat id
>delegate_to: localhost
>debug:
>  msg:
>   - "Tenant ID:"
>   - "{{ tenantid.stdout }}"
>   - "==="
>   - "Instance ID of the VMs in TOM
>   - "{{ instid.stdout_lines}}"

When using register with with_items/loop you'll have instid.results which is a 
list where each item contain the output for each command.

When you get errors like this always run a
  - debug: var=instid

-- 
Kai Stian Olstad

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ad12016d-c5e5-c89b-c225-1d6d99edaedc%40olstad.com.


Re: [ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Karl Auer
What is the *complete* output from a debug of instid?


Regards, K.


On Wed, Sep 25, 2019 at 3:06 AM Rakesh Parida 
wrote:

> Hi,
>
> I have  playbook to retrieve the Instance id of Openstack nodes.Now
> everything works fine but the resgitered value for instid.stdout_lines gets
> an undefined error.
> *The error was: 'dict object' has no attribute 'stdout_lines'* .. but
> when i debug the complete registered variable instid i see stdout_lines.
> but why its failing when i debug it using instid.stdout_lines
>
>  "item": "TOMCS2",
> "rc": 0,
> "start": "2019-09-24 09:15:45.801051",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804
> TOMICS2",
> *"stdout_lines": [*
> *"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*
>
>
> - hosts: nodes[0]
>   gather_facts: false
>   tasks:
> - name: Collect  Hostnames
>   set_fact:
>  host_lists: "{{ hostvars[inventory_hostname]['groups']['nodes']
> }}"
>
> - name: Create Hostname as per the Name in openstack names
>   set_fact:
>  fact: '{{ (["TOM"] *
> host_lists|length)|zip(host_lists)|map("join")|list}}'
>
> - name: Debug the required list
>   debug:
> msg: "{{ fact }}"
>
>
> - hosts: 127.0.0.1
>   gather_facts: false
>   tasks:
> - name: Retrieve tenantID
>   shell: openstack project list | awk '/ TOM / { print $2 }'
>   register: tenantid
>
>  - name: Retrieve instance id from tenant
>shell: openstack server list --all-projects --project "{{
> tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
>with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}"
>register: instid
>
> - name: Debug Instance id and Tennat id
>   delegate_to: localhost
>   debug:
> msg:
>  - "Tenant ID:"
>  - "{{ tenantid.stdout }}"
>  - "==="
>  - "Instance ID of the VMs in TOM
>  - "{{ instid.stdout_lines}}"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cc57f323-5d44-4b9b-97e9-ccc1e9f19542%40googlegroups.com
> 
> .
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816

-- 
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/CA%2B%2BT08QYC5y4gQJ5OtthTRVZaS5TmRU7qxtoCjrJRNq3w8Y%2Bew%40mail.gmail.com.


[ansible-project] Getting error for ".stdout_lines" for a registered variable

2019-09-24 Thread Rakesh Parida
Hi,

I have  playbook to retrieve the Instance id of Openstack nodes.Now 
everything works fine but the resgitered value for instid.stdout_lines gets 
an undefined error.
*The error was: 'dict object' has no attribute 'stdout_lines'* .. but when 
i debug the complete registered variable instid i see stdout_lines. but why 
its failing when i debug it using instid.stdout_lines

 "item": "TOMCS2", 
"rc": 0, 
"start": "2019-09-24 09:15:45.801051", 
"stderr": "", 
"stderr_lines": [], 
"stdout": "e8ebc5a4-17f3-4b80-a935-03164211a804 
TOMICS2", 
*"stdout_lines": [*
*"e8ebc5a4-17f3-4b80-a935-03164211a804 TOMCS2"*


- hosts: nodes[0]
  gather_facts: false
  tasks:
- name: Collect  Hostnames
  set_fact:
 host_lists: "{{ hostvars[inventory_hostname]['groups']['nodes'] }}"

- name: Create Hostname as per the Name in openstack names
  set_fact:
 fact: '{{ (["TOM"] * 
host_lists|length)|zip(host_lists)|map("join")|list}}'

- name: Debug the required list
  debug:
msg: "{{ fact }}"


- hosts: 127.0.0.1
  gather_facts: false
  tasks:
- name: Retrieve tenantID
  shell: openstack project list | awk '/ TOM / { print $2 }'
  register: tenantid

 - name: Retrieve instance id from tenant
   shell: openstack server list --all-projects --project "{{ 
tenantid.stdout }}" | awk 'NR > 3 { print $2, $4 }' | grep -i "{{ item }}"
   with_items: "{{ hostvars[groups['nodes'][0]]['fact'] }}"
   register: instid

- name: Debug Instance id and Tennat id
  delegate_to: localhost
  debug:
msg:
 - "Tenant ID:"
 - "{{ tenantid.stdout }}"
 - "==="
 - "Instance ID of the VMs in TOM
 - "{{ instid.stdout_lines}}"

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cc57f323-5d44-4b9b-97e9-ccc1e9f19542%40googlegroups.com.


[ansible-project] Ansible apt module question (Repository issues)

2019-09-24 Thread Tobias Klenota
Hi,

i,m getting the "public key is not avaiable" error while using the apt 
module.(installing zabbix agent)
I know i could just add the key, but my question is:

Why does this error occure while im using ansible and its apt-module, but 
if i log into the server directly and use apt install i wont get any errors?
Shouldn't this be exactly the same or whats the difference?

kind 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/b85bba30-2a4e-4729-80f3-e576a4ab88cc%40googlegroups.com.


Re: [ansible-project] Ansible Playbook and Jenkins

2019-09-24 Thread Vikrant Kaushik
Got it, thanks

On Tuesday, 24 September 2019 18:43:30 UTC+5:30, Jonathan Lozada De La 
Matta wrote:
>
> this is the community alias.
>
> On Tue, Sep 24, 2019 at 9:09 AM Vikrant  > wrote:
>
>> Hi Jonathan,
>>
>> I'll check it out, but if you can share any official Redhat Ansible then 
>> it would be great.
>>
>> regards
>>
>> Vikrant
>>
>> On Tue, Sep 24, 2019 at 6:18 PM Jonathan Lozada De La Matta <
>> jloz...@redhat.com > wrote:
>>
>>> This is a long conversation. I suggest you google this topic as there's 
>>> blogs and instructions out there.
>>>
>>> On Tue, Sep 24, 2019 at 8:24 AM Vikrant Kaushik >> > wrote:
>>>
 Hi,

 Can anybody advise how to run Ansible Playbook using Jenkins and how to 
 integrate.

 regards

 Vikrant

 -- 
 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/cc327be9-4b60-4b21-9ea7-047d6671d622%40googlegroups.com
  
 
 .

>>> -- 
>>>
>>> Jonathan Cha'gara Lozada De La Matta 
>>>
>>> He / Him / His
>>>
>>> Red Hat  
>>>
>>> Senior Automation Practice Consultant & Automation CoP Manager
>>>
>>> Join the Automation CoP! https://red.ht/autocop
>>> @redhatjobs    redhatjobs 
>>>  @redhatjobs 
>>>    
>>>  
>>>  
>>>
>>> -- 
>>> 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/CAFYJA%2BKXcpp1AhThbgXDEwtfhp7wc92gmOfSGZA%3DjFf2aqTX3A%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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CA%2BB%2B_htESfH_%2Bu4qnrtA5ME7mqwpbnVL%3D-fE7r1qd3ockrQJ3A%40mail.gmail.com
>>  
>> 
>> .
>>
> -- 
>
> Jonathan Cha'gara Lozada De La Matta 
>
> He / Him / His
>
> Red Hat  
>
> Senior Automation Practice Consultant & Automation CoP Manager
>
> Join the Automation CoP! https://red.ht/autocop
> @redhatjobs    redhatjobs 
>  @redhatjobs 
>    
>  
>  
>
>

-- 
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/681f5dd2-d30b-4124-8811-7a36592c5732%40googlegroups.com.


Re: [ansible-project] Ansible Playbook and Jenkins

2019-09-24 Thread Jonathan Lozada De La Matta
this is the community alias.

On Tue, Sep 24, 2019 at 9:09 AM Vikrant  wrote:

> Hi Jonathan,
>
> I'll check it out, but if you can share any official Redhat Ansible then
> it would be great.
>
> regards
>
> Vikrant
>
> On Tue, Sep 24, 2019 at 6:18 PM Jonathan Lozada De La Matta <
> jloza...@redhat.com> wrote:
>
>> This is a long conversation. I suggest you google this topic as there's
>> blogs and instructions out there.
>>
>> On Tue, Sep 24, 2019 at 8:24 AM Vikrant Kaushik <
>> kaushik.vikr...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> Can anybody advise how to run Ansible Playbook using Jenkins and how to
>>> integrate.
>>>
>>> regards
>>>
>>> Vikrant
>>>
>>> --
>>> 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/cc327be9-4b60-4b21-9ea7-047d6671d622%40googlegroups.com
>>> 
>>> .
>>>
>> --
>>
>> Jonathan Cha'gara Lozada De La Matta
>>
>> He / Him / His
>>
>> Red Hat 
>>
>> Senior Automation Practice Consultant & Automation CoP Manager
>>
>> Join the Automation CoP! https://red.ht/autocop
>> @redhatjobs    redhatjobs
>>  @redhatjobs
>> 
>> 
>>
>>
>> --
>> 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/CAFYJA%2BKXcpp1AhThbgXDEwtfhp7wc92gmOfSGZA%3DjFf2aqTX3A%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/CA%2BB%2B_htESfH_%2Bu4qnrtA5ME7mqwpbnVL%3D-fE7r1qd3ockrQJ3A%40mail.gmail.com
> 
> .
>
-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2BJ5TSZaeLNDgBgN6Sz70cmkM0nxuX-OgtLOUX1udR%3D4YQ%40mail.gmail.com.


Re: [ansible-project] Ansible Playbook and Jenkins

2019-09-24 Thread Vikrant
Hi Jonathan,

I'll check it out, but if you can share any official Redhat Ansible then it
would be great.

regards

Vikrant

On Tue, Sep 24, 2019 at 6:18 PM Jonathan Lozada De La Matta <
jloza...@redhat.com> wrote:

> This is a long conversation. I suggest you google this topic as there's
> blogs and instructions out there.
>
> On Tue, Sep 24, 2019 at 8:24 AM Vikrant Kaushik 
> wrote:
>
>> Hi,
>>
>> Can anybody advise how to run Ansible Playbook using Jenkins and how to
>> integrate.
>>
>> regards
>>
>> Vikrant
>>
>> --
>> 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/cc327be9-4b60-4b21-9ea7-047d6671d622%40googlegroups.com
>> 
>> .
>>
> --
>
> Jonathan Cha'gara Lozada De La Matta
>
> He / Him / His
>
> Red Hat 
>
> Senior Automation Practice Consultant & Automation CoP Manager
>
> Join the Automation CoP! https://red.ht/autocop
> @redhatjobs    redhatjobs
>  @redhatjobs
> 
> 
>
>
> --
> 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/CAFYJA%2BKXcpp1AhThbgXDEwtfhp7wc92gmOfSGZA%3DjFf2aqTX3A%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/CA%2BB%2B_htESfH_%2Bu4qnrtA5ME7mqwpbnVL%3D-fE7r1qd3ockrQJ3A%40mail.gmail.com.


Re: [ansible-project] Ansible Playbook and Jenkins

2019-09-24 Thread Jonathan Lozada De La Matta
This is a long conversation. I suggest you google this topic as there's
blogs and instructions out there.

On Tue, Sep 24, 2019 at 8:24 AM Vikrant Kaushik 
wrote:

> Hi,
>
> Can anybody advise how to run Ansible Playbook using Jenkins and how to
> integrate.
>
> regards
>
> Vikrant
>
> --
> 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/cc327be9-4b60-4b21-9ea7-047d6671d622%40googlegroups.com
> 
> .
>
-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2BKXcpp1AhThbgXDEwtfhp7wc92gmOfSGZA%3DjFf2aqTX3A%40mail.gmail.com.


[ansible-project] Ansible Playbook and Jenkins

2019-09-24 Thread Vikrant Kaushik
Hi,

Can anybody advise how to run Ansible Playbook using Jenkins and how to 
integrate.

regards

Vikrant

-- 
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/cc327be9-4b60-4b21-9ea7-047d6671d622%40googlegroups.com.


Re: [ansible-project] Connection via Citrix

2019-09-24 Thread James Cassell


On Tue, Sep 24, 2019, at 7:35 AM, Srinivas Naram wrote:
> Hello Gurus,
> 
> Few devices in my customer environment can be connected via Citrix. How 
> to connect to devices which are accessible only via Citrix using 
> Ansible ?
> 

I'd guess this is not possible by design, though I would be interested if you 
found a way to do it.

V/r,
James Cassell

-- 
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/55fa842c-37cd-4dcd-bcde-d8d8a8c7092a%40www.fastmail.com.


[ansible-project] Connection via Citrix

2019-09-24 Thread Srinivas Naram
Hello Gurus,

Few devices in my customer environment can be connected via Citrix. How to 
connect to devices which are accessible only via Citrix using Ansible ?

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/d1bff7ea-9805-47f1-98c7-b5677321d763%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
Can you suggest what is the issue with this code ?

   - name: Add hosts
 include_tasks: "{{ playbook_dir }}/gethosts.yml"
   dest_ip: "{{ item.split('\t')[0] }}"
   groups: dest_nodes
   file_dets: "{{ item.split('\t')[1] }}"
   ansible_host: localhost
   ansible_connection: local
 with_items: "{{ command_result.stdout_lines }}"


And below is my get_hosts.yml file

 add_host:
   name: "{{ item }}"   
 with_items: "{{ dest_ip.split(',') }}"

On Tuesday, September 24, 2019 at 2:01:17 PM UTC+5:30, Vladimir Botka wrote:
>
> On Mon, 23 Sep 2019 23:44:58 -0700 (PDT) 
> Mohtashim S > wrote: 
>
> > command_result variable has has data like below. 
> > 
> > host6,host5\targ3 
> > host4,host3\targ1 
> > host1,host2,host5\targ2 
> > . 
> > . 
> > 
> > I need to loop through each line of command_result. Pick the host list 
> for 
> > example host6,host5 and execute shell script using shell module by 
> passing 
> > respective argument string i.e arg3. 
>
> Given the input is a list 'db_lines' normalise the data first. For example 
> the loop below 
>
>   vars: 
> separator: '\t' 
> db_lines: 
>   - 'host6,host5\targ3' 
>   - 'host4,host3\targ1' 
>   - 'host1,host2,host5\targ2' 
>   tasks: 
> - set_fact: 
> my_data: "{{ my_data|default([]) + 
>  [{'host': item.split(separator)[0].split(','), 
>'arg': item.split(separator)[1].split(',')}] }}" 
>   loop: "{{ db_lines }}" 
>
> gives 
>
>   my_data: 
>   - arg: 
> - arg3 
> host: 
> - host6 
> - host5 
>   - arg: 
> - arg1 
> host: 
> - host4 
> - host3 
>   - arg: 
> - arg2 
> host: 
> - host1 
> - host2 
> - host5 
>
> It should be trivial to use it in the loops. 
>
> Cheers, 
>
> -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/b560e24a-c84a-46e2-9672-383f4ba648f0%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
Can you suggest what is the issue with this code ?

   - name: Add hosts
 include_tasks: "{{ playbook_dir }}/gethosts.yml"
   dest_ip: "{{ item.split('\t')[0] }}"
   groups: dest_nodes
   file_dets: "{{ item.split('\t')[1] }}"
   ansible_host: localhost
   ansible_connection: local
 with_items: "{{ command_result.stdout_lines }}"


And below is my get_hosts.yml file

 add_host:
   name: {{ item }}   
 with_items: "{{ dest_ip.split(',') }}"



On Tuesday, September 24, 2019 at 2:51:40 PM UTC+5:30, Mohtashim S wrote:
>
> The input data is not a fixed list but can be any number of lines returned 
> by the database and registered by variable "command_result" as below":
>
> - name: "Play 1"
>   hosts: localhost
>   tasks:
>- name: "Search DB"
>  command: >   mysql --user=root --password=p@ssword deployment
>--host=localhost  -Ns -e "SELECT dest_ip,file_dets FROM 
> deploy_dets WHERE num LIKE '{{ CR_Number }}'"
>  register: command_result
>
>
> Kindly suggest.
>
> On Tuesday, September 24, 2019 at 2:01:17 PM UTC+5:30, Vladimir Botka 
> wrote:
>>
>> On Mon, 23 Sep 2019 23:44:58 -0700 (PDT) 
>> Mohtashim S  wrote: 
>>
>> > command_result variable has has data like below. 
>> > 
>> > host6,host5\targ3 
>> > host4,host3\targ1 
>> > host1,host2,host5\targ2 
>> > . 
>> > . 
>> > 
>> > I need to loop through each line of command_result. Pick the host list 
>> for 
>> > example host6,host5 and execute shell script using shell module by 
>> passing 
>> > respective argument string i.e arg3. 
>>
>> Given the input is a list 'db_lines' normalise the data first. For 
>> example 
>> the loop below 
>>
>>   vars: 
>> separator: '\t' 
>> db_lines: 
>>   - 'host6,host5\targ3' 
>>   - 'host4,host3\targ1' 
>>   - 'host1,host2,host5\targ2' 
>>   tasks: 
>> - set_fact: 
>> my_data: "{{ my_data|default([]) + 
>>  [{'host': item.split(separator)[0].split(','), 
>>'arg': item.split(separator)[1].split(',')}] }}" 
>>   loop: "{{ db_lines }}" 
>>
>> gives 
>>
>>   my_data: 
>>   - arg: 
>> - arg3 
>> host: 
>> - host6 
>> - host5 
>>   - arg: 
>> - arg1 
>> host: 
>> - host4 
>> - host3 
>>   - arg: 
>> - arg2 
>> host: 
>> - host1 
>> - host2 
>> - host5 
>>
>> It should be trivial to use it in the loops. 
>>
>> Cheers, 
>>
>> -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/53e52a27-15fc-42d0-adfd-d66bf1afdb79%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
The input data is not a fixed list but can be any number of lines returned 
by the database and registered by variable "command_result" as below":

- name: "Play 1"
  hosts: localhost
  tasks:
   - name: "Search DB"
 command: >   mysql --user=root --password=p@ssword deployment
   --host=localhost  -Ns -e "SELECT dest_ip,file_dets FROM deploy_dets 
WHERE num LIKE '{{ CR_Number }}'"
 register: command_result


Kindly suggest.

On Tuesday, September 24, 2019 at 2:01:17 PM UTC+5:30, Vladimir Botka wrote:
>
> On Mon, 23 Sep 2019 23:44:58 -0700 (PDT) 
> Mohtashim S > wrote: 
>
> > command_result variable has has data like below. 
> > 
> > host6,host5\targ3 
> > host4,host3\targ1 
> > host1,host2,host5\targ2 
> > . 
> > . 
> > 
> > I need to loop through each line of command_result. Pick the host list 
> for 
> > example host6,host5 and execute shell script using shell module by 
> passing 
> > respective argument string i.e arg3. 
>
> Given the input is a list 'db_lines' normalise the data first. For example 
> the loop below 
>
>   vars: 
> separator: '\t' 
> db_lines: 
>   - 'host6,host5\targ3' 
>   - 'host4,host3\targ1' 
>   - 'host1,host2,host5\targ2' 
>   tasks: 
> - set_fact: 
> my_data: "{{ my_data|default([]) + 
>  [{'host': item.split(separator)[0].split(','), 
>'arg': item.split(separator)[1].split(',')}] }}" 
>   loop: "{{ db_lines }}" 
>
> gives 
>
>   my_data: 
>   - arg: 
> - arg3 
> host: 
> - host6 
> - host5 
>   - arg: 
> - arg1 
> host: 
> - host4 
> - host3 
>   - arg: 
> - arg2 
> host: 
> - host1 
> - host2 
> - host5 
>
> It should be trivial to use it in the loops. 
>
> Cheers, 
>
> -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/807413db-6585-49c5-a8f9-8a51b8d39f87%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Vladimir Botka
On Mon, 23 Sep 2019 23:44:58 -0700 (PDT)
Mohtashim S  wrote:

> command_result variable has has data like below.
> 
> host6,host5\targ3
> host4,host3\targ1
> host1,host2,host5\targ2
> .
> .
> 
> I need to loop through each line of command_result. Pick the host list for 
> example host6,host5 and execute shell script using shell module by passing 
> respective argument string i.e arg3.

Given the input is a list 'db_lines' normalise the data first. For example
the loop below

  vars:
separator: '\t'
db_lines:
  - 'host6,host5\targ3'
  - 'host4,host3\targ1'
  - 'host1,host2,host5\targ2'
  tasks:
- set_fact:
my_data: "{{ my_data|default([]) +
 [{'host': item.split(separator)[0].split(','),
   'arg': item.split(separator)[1].split(',')}] }}"
  loop: "{{ db_lines }}"

gives

  my_data:
  - arg:
- arg3
host:
- host6
- host5
  - arg:
- arg1
host:
- host4
- host3
  - arg:
- arg2
host:
- host1
- host2
- host5

It should be trivial to use it in the loops.

Cheers,

-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/20190924103105.29220bf7%40gmail.com.


pgpEn2glT8xf5.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
@Dick; I need more help please. 

This is what I did but it is still failing. 

   - name: Add hosts
 include_tasks: "{{ playbook_dir }}/gethosts.yml"
   dest_ip: "{{ item.split('\t')[0] }}"
   groups: dest_nodes
   file_dets: "{{ item.split('\t')[1] }}"
   ansible_host: localhost
   ansible_connection: local
 with_items: "{{ command_result.stdout_lines }}"

And below is my get_hosts.yml file

 add_host:
   name: {{ item }}   
 with_items: "{{ dest_ip.split(',') }}"


On Tuesday, September 24, 2019 at 12:29:21 PM UTC+5:30, Dick Visser wrote:
>
> Instead of using add_host, use include_tasks to include a second task 
> file. In there, iterate over a “split by comma” list and adds hosts. 
> This gives you the second level of iteration. 
>
> Dick 
>
> On Tue, 24 Sep 2019 at 08:45, Mohtashim S  > wrote:
>
>> I have an ansible play that fetches multiline data from the database and 
>> registers it a variable "command_result"
>>
>> command_result variable has has data like below.
>>
>> host6,host5\targ3
>> host4,host3\targ1
>>
>> host1,host2,host5\targ2
>> .
>> .
>>
>>
>>
>> I need to loop through each line of command_result. Pick the host list 
>> for example host6,host5 and execute shell script using shell module by 
>> passing respective argument string i.e arg3.
>>
>> Likewise, the second shell script should run on  host4 & host3 and pass 
>> arg1 to the shell script. 
>>
>> The final shell script hould run on  host1, host2 & host5 and pass arg2 
>> to the shell script. 
>>
>>- name: Add hosts
>>  add_host:
>>name: "{{ item.split('\t')[0] }}"
>>file_dets: "{{ item.split('\t')[1] }}"
>>
>>ansible_host: localhost
>>
>>ansible_connection: local
>>groups: dest_nodes
>>  with_items: "{{ command_result.stdout_lines }}"
>>
>>
>> - hosts: dest_nodes
>>   gather_facts: false
>>   tasks:
>> - debug:
>> msg: Run the shell script with the arguments `{{ file_dets }}` 
>> here"
>>
>>
>> This works fine when there is a single host in  item.split('\t')[0]
>>
>> However, I do not know the approach when there are multiple hosts like 
>> host6,host5 for {{ item.split('\t')[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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/ef6c8ef7-7462-4e05-8025-7d1f514329b7%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/25e9a157-8733-4de0-a10f-2f48ffa99798%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
@Dick; I need more help please. 

This is what I did but it is still failing. 

   - name: Add hosts

   dest_ip: "{{ item.split('\t')[0] }}"

   file_dets: "{{ item.split('\t')[1] }}"
   ansible_host: localhost

   ansible_connection: local
 with_items: "{{ command_result.stdout_lines }}"


   - include: "{{ playbook_dir }}/gethosts.yml"




And below is my get_hosts.yml file

 add_host:
   name: {{ item }}
   groups: dest_nodes 
 with_items: "{{ dest_ip.split(',') }}"
 when: command_result.stdout != ""
 failed_when: command_result.stdout == ""

It is giving me errors while executing. 


On Tuesday, September 24, 2019 at 12:29:21 PM UTC+5:30, Dick Visser wrote:
>
> Instead of using add_host, use include_tasks to include a second task 
> file. In there, iterate over a “split by comma” list and adds hosts. 
> This gives you the second level of iteration. 
>
> Dick 
>
> On Tue, 24 Sep 2019 at 08:45, Mohtashim S  > wrote:
>
>> I have an ansible play that fetches multiline data from the database and 
>> registers it a variable "command_result"
>>
>> command_result variable has has data like below.
>>
>> host6,host5\targ3
>> host4,host3\targ1
>>
>> host1,host2,host5\targ2
>> .
>> .
>>
>>
>>
>> I need to loop through each line of command_result. Pick the host list 
>> for example host6,host5 and execute shell script using shell module by 
>> passing respective argument string i.e arg3.
>>
>> Likewise, the second shell script should run on  host4 & host3 and pass 
>> arg1 to the shell script. 
>>
>> The final shell script hould run on  host1, host2 & host5 and pass arg2 
>> to the shell script. 
>>
>>- name: Add hosts
>>  add_host:
>>name: "{{ item.split('\t')[0] }}"
>>file_dets: "{{ item.split('\t')[1] }}"
>>
>>ansible_host: localhost
>>
>>ansible_connection: local
>>groups: dest_nodes
>>  with_items: "{{ command_result.stdout_lines }}"
>>
>>
>> - hosts: dest_nodes
>>   gather_facts: false
>>   tasks:
>> - debug:
>> msg: Run the shell script with the arguments `{{ file_dets }}` 
>> here"
>>
>>
>> This works fine when there is a single host in  item.split('\t')[0]
>>
>> However, I do not know the approach when there are multiple hosts like 
>> host6,host5 for {{ item.split('\t')[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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/ef6c8ef7-7462-4e05-8025-7d1f514329b7%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/8f6fa0b3-4eae-43db-9a85-0bc82d4780ee%40googlegroups.com.


[ansible-project] How to login to webpage using ansible ?

2019-09-24 Thread kasturi vivek
How to login to any webpage(having to log in ID and Password) and need to 
attach the file in the page(website page0 by using ansible. could you 
please help me with this 


- name: Check url
  uri:
url: https:www.facebook.com

- name: login check
  uri:
url:https:www.facebook.com
method: GET
user: Admin
password: admin
force_basic_auth: yes
status_code: 200

Here I used facebook as example could you please help me on this

-- 
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/eb2887e7-c077-4158-9d3b-b40fe24e50f5%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
@Dick; I need more help please. 

This is what I did but it is still failing. 

   - name: Add hosts
 include_tasks: "{{ playbook_dir }}/gethosts.yml"
   file_dets: "{{ item.split('\t')[1] }}"
   ansible_host: localhost
   ansible_connection: local
 with_items: "{{ command_result.stdout_lines }}"


- hosts: dest_nodes
  gather_facts: false
  tasks:
- debug:
msg: Run the shell script with the arguments `{{ file_dets }}` here"


And below is my gethosts.yml

 add_host:
   name: {{ item }}
   groups: dest_nodes
 with_items: "{{ item.split('\t')[0].split(',') }}"
 when: command_result.stdout != ""





On Tuesday, September 24, 2019 at 12:29:21 PM UTC+5:30, Dick Visser wrote:
>
> Instead of using add_host, use include_tasks to include a second task 
> file. In there, iterate over a “split by comma” list and adds hosts. 
> This gives you the second level of iteration. 
>
> Dick 
>
> On Tue, 24 Sep 2019 at 08:45, Mohtashim S  > wrote:
>
>> I have an ansible play that fetches multiline data from the database and 
>> registers it a variable "command_result"
>>
>> command_result variable has has data like below.
>>
>> host6,host5\targ3
>> host4,host3\targ1
>>
>> host1,host2,host5\targ2
>> .
>> .
>>
>>
>>
>> I need to loop through each line of command_result. Pick the host list 
>> for example host6,host5 and execute shell script using shell module by 
>> passing respective argument string i.e arg3.
>>
>> Likewise, the second shell script should run on  host4 & host3 and pass 
>> arg1 to the shell script. 
>>
>> The final shell script hould run on  host1, host2 & host5 and pass arg2 
>> to the shell script. 
>>
>>- name: Add hosts
>>  add_host:
>>name: "{{ item.split('\t')[0] }}"
>>file_dets: "{{ item.split('\t')[1] }}"
>>
>>ansible_host: localhost
>>
>>ansible_connection: local
>>groups: dest_nodes
>>  with_items: "{{ command_result.stdout_lines }}"
>>
>>
>> - hosts: dest_nodes
>>   gather_facts: false
>>   tasks:
>> - debug:
>> msg: Run the shell script with the arguments `{{ file_dets }}` 
>> here"
>>
>>
>> This works fine when there is a single host in  item.split('\t')[0]
>>
>> However, I do not know the approach when there are multiple hosts like 
>> host6,host5 for {{ item.split('\t')[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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/ef6c8ef7-7462-4e05-8025-7d1f514329b7%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/ec84d98a-caf2-4358-a77f-bbadd6c115f6%40googlegroups.com.


Re: [ansible-project] How to trigger Ansible Play in a loop

2019-09-24 Thread Mohtashim S
@Stefan, thank you for the reply. 

I have rephrased my query and posted to a new thread here: 
https://groups.google.com/forum/#!topic/ansible-project/tzFtb4MRZN0

Please suggest as feasible. 

On Monday, September 23, 2019 at 10:25:44 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 9/23/19 2:50 PM, Mohtashim S wrote: 
> > command_result variable get database record while could be multi-line. 
> > 
> > The below helps me loop over each record of the database. 
> > 
> > | 
> >-debug: 
> >msg:"This is a database line: {{ item }}" 
> >  with_items:"{{ command_result.stdout_lines }}" 
> > | 
> > 
> > What I now need is to trigger a fresh play like below for each loop 
> iteration and its values. 
> > 
> > | 
> > -hosts:"{{ item.stdout.split('\t')[0] }}" 
> >   tasks: 
> > -name:Checkifreboot isrequired 
> >   shell:/home/ansible/scripts/check.sh "{{ 
> item.stdout.split('\t')[1] }}" 
> >   register:output 
> > 
> > 
> > -debug:var=output.stdout_lines 
> > 
> > 
> >-add_host:name={{item }} 
> >groups=dest_nodes 
> >ansible_user={{USER }} 
> >  with_items:"{{ dest_ip.split(',') }}" 
> > | 
> > 
> > The item value will change on each loop and that will be fed to the play 
> above.  
> > 
> > Can you please guide me how to achieve this ? 
>
> What do you mean with "trigger a fresh play" ? 
>
> Regards 
>   Racke 
>
> > 
> > -- 
> > 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   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/6a730169-fd2b-4a34-836e-2addb50d8490%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/6a730169-fd2b-4a34-836e-2addb50d8490%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
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/864934e3-27a2-4be5-824a-2890d022618a%40googlegroups.com.


Re: [ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Dick Visser
Instead of using add_host, use include_tasks to include a second task file.
In there, iterate over a “split by comma” list and adds hosts.
This gives you the second level of iteration.

Dick

On Tue, 24 Sep 2019 at 08:45, Mohtashim S  wrote:

> I have an ansible play that fetches multiline data from the database and
> registers it a variable "command_result"
>
> command_result variable has has data like below.
>
> host6,host5\targ3
> host4,host3\targ1
>
> host1,host2,host5\targ2
> .
> .
>
>
>
> I need to loop through each line of command_result. Pick the host list for
> example host6,host5 and execute shell script using shell module by passing
> respective argument string i.e arg3.
>
> Likewise, the second shell script should run on  host4 & host3 and pass
> arg1 to the shell script.
>
> The final shell script hould run on  host1, host2 & host5 and pass arg2 to
> the shell script.
>
>- name: Add hosts
>  add_host:
>name: "{{ item.split('\t')[0] }}"
>file_dets: "{{ item.split('\t')[1] }}"
>
>ansible_host: localhost
>
>ansible_connection: local
>groups: dest_nodes
>  with_items: "{{ command_result.stdout_lines }}"
>
>
> - hosts: dest_nodes
>   gather_facts: false
>   tasks:
> - debug:
> msg: Run the shell script with the arguments `{{ file_dets }}`
> here"
>
>
> This works fine when there is a single host in  item.split('\t')[0]
>
> However, I do not know the approach when there are multiple hosts like
> host6,host5 for {{ item.split('\t')[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/ef6c8ef7-7462-4e05-8025-7d1f514329b7%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/CAL8fbwMbqDejy9YNhgzQvOmWayu03Dj8QjE0nS7Waj0ZY-zvLQ%40mail.gmail.com.


[ansible-project] Issues generating dynamic host in Ansible loop.

2019-09-24 Thread Mohtashim S
I have an ansible play that fetches multiline data from the database and 
registers it a variable "command_result"

command_result variable has has data like below.

host6,host5\targ3
host4,host3\targ1

host1,host2,host5\targ2
.
.



I need to loop through each line of command_result. Pick the host list for 
example host6,host5 and execute shell script using shell module by passing 
respective argument string i.e arg3.

Likewise, the second shell script should run on  host4 & host3 and pass 
arg1 to the shell script. 

The final shell script hould run on  host1, host2 & host5 and pass arg2 to 
the shell script. 

   - name: Add hosts
 add_host:
   name: "{{ item.split('\t')[0] }}"
   file_dets: "{{ item.split('\t')[1] }}"

   ansible_host: localhost

   ansible_connection: local
   groups: dest_nodes
 with_items: "{{ command_result.stdout_lines }}"


- hosts: dest_nodes
  gather_facts: false
  tasks:
- debug:
msg: Run the shell script with the arguments `{{ file_dets }}` here"


This works fine when there is a single host in  item.split('\t')[0]

However, I do not know the approach when there are multiple hosts like 
host6,host5 for {{ item.split('\t')[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/ef6c8ef7-7462-4e05-8025-7d1f514329b7%40googlegroups.com.


[ansible-project] Cisco switch identifying unused port more than 90 days

2019-09-24 Thread rajthecomputerguy
Hi Team,

I want to identify the switch ports which are not used more than 90 days. 
Has anyone done this project using ansible ? 

Thanks
Pushparaj

-- 
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/32948aaa-2b53-46a2-a83c-5a98ae5669e7%40googlegroups.com.