[ansible-project] Re: Need Assistance With Ansible Error

2020-04-14 Thread George James
Thanks Orkhan, but the same issue 

On Wednesday, April 15, 2020 at 8:54:51 AM UTC+4, Orkhan Mammadov wrote:
>
> Run the file from the directory, where your config file is located.
>
> On Wednesday, April 15, 2020 at 7:46:36 AM UTC+4, George James wrote:
>>
>> I am new to ansible.
>>
>> I create an inventory file 
>>
>> [web] 
>> 167.172.xxx.xxx ansible_connection=ssh ansible_user=root 
>> ansible_ssh_private_key_file=~/.ssh/id_rsa.pub
>>
>> Then I run 
>>
>> ansible web -m ping -i hosts -
>>
>> But I am presented with the following log and error
>>
>>
>> ansible 2.9.6
>>   config file = None
>>   configured module search path = 
>> ['/Users/g.james/.ansible/plugins/modules', 
>> '/usr/share/ansible/plugins/modules']
>>   ansible python module location = 
>> /usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible
>>   executable location = /usr/local/bin/ansible
>>   python version = 3.8.2 (default, Mar 11 2020, 00:29:50) [Clang 11.0.0 
>> (clang-1100.0.33.17)]
>> No config file found; using defaults
>> setting up inventory plugins
>> host_list declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as 
>> it did not pass its verify_file() method
>> script declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it 
>> did not pass its verify_file() method
>> auto declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it 
>> did not pass its verify_file() method
>> Parsed /Users/g.james/dojo360/d3-scripts/server/hosts inventory source with 
>> ini plugin
>> Loading callback plugin minimal of type stdout, v2.0 from 
>> /usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible/plugins/callback/minimal.py
>> META: ran handlers
>> <67.172.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
>> <67.172.xxx.xxx> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
>> ControlPersist=60s -o 'IdentityFile="/Users/g.james/.ssh/id_rsa.pub"' -o 
>> KbdInteractiveAuthentication=no -o 
>> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
>> PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 
>> ControlPath=/Users/g.james/.ansible/cp/5d3d6b8351 67.172.xxx.xxx '/bin/sh -c 
>> '"'"'echo ~root && sleep 0'"'"''
>> <67.172.xxx.xxx> (255, b'', b'OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: 
>> Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
>> /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: 
>> resolve_canonicalize: hostname 67.172.xxx.xxx is address\r\ndebug1: 
>> auto-mux: Trying existing master\r\ndebug1: Control socket 
>> "/Users/g.james/.ansible/cp/5d3d6b8351" does not exist\r\ndebug2: 
>> ssh_connect_direct\r\ndebug1: Connecting to 67.172.xxx.xxx [67.172.xxx.xxx] 
>> port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: connect to address 
>> 67.172.xxx.xxx port 22: Operation timed out\r\nssh: connect to host 
>> 67.172.xxx.xxx port 22: Operation timed out\r\n')
>> 67.172.xxx.xxx | UNREACHABLE! => {
>> "changed": false,
>> "msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1, LibreSSL 
>> 2.7.3\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
>> /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: 
>> resolve_canonicalize: hostname 67.172.xxx.xxx is address\r\ndebug1: 
>> auto-mux: Trying existing master\r\ndebug1: Control socket 
>> \"/Users/g.james/.ansible/cp/5d3d6b8351\" does not exist\r\ndebug2: 
>> ssh_connect_direct\r\ndebug1: Connecting to 67.172.xxx.xxx [67.172.xxx.xxx] 
>> port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: connect to address 
>> 67.172.xxx.xxx port 22: Operation timed out\r\nssh: connect to host 
>> 67.172.xxx.xxx port 22: Operation timed out",
>> "unreachable": true
>> }
>>
>> Please I need help, I have been stuck on this for 48 hours, tried different 
>> computers  and VMs all returns back the same result
>>
>>

-- 
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/32323a26-0f2f-4381-a3ef-ff2be0bc94a7%40googlegroups.com.


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

2020-04-14 Thread Suresh Karpurapu
Would anyone please help me with this?

Regards,
Suresh

On Tue, 14 Apr 2020, 7:32 pm Suresh Karpurapu, 
wrote:

> Hi Vladimir, thanks for your help all the time.
>
> I tried using the logic, and it worked when apply the values to debug but
> the same data is passing to mount module with additional quotes and
> brackets which is causing the errors. Any suggestions please?
>
> Playbook and CSV details:
> =
>
> # cat mounts.csv
> host,remote_path,mnt_path,python
>
> host1,nfsflr01:/volahcstg_www_masup_stg_data_01,/myasup/stg/data,/usr/bin/python2.6
>
> host2,nfsflr01:/volahcstg_www_masup_stg_data_01,/myasup/stg/data,/usr/bin/python2.6
> # 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
> - name: Grouping host and volume information
>   add_host:
> name: "{{ item.0 }}"
> groups: nfsgroup
> var1: "{{ item.1|json_query('[].remote_path') }}"
> var2: "{{ item.1|json_query('[].mnt_path') }}"
> ansible_python_interpreter: "{{ item.1.0.python }}"
>   loop: "{{ sources.list|groupby('host') }}"
> - name: list the volumes
>   hosts: nfsgroup
>   become: yes
>   gather_facts: false
>   tasks:
> - name: debug output
>   debug:
> msg:
>   - "{{ inventory_hostname }}"
>   - "{{ var1 }}"
>   - "{{ var2 }}"
> - name: mounting the volume in the fstab file
>   hosts: nfsgroup
>   gather_facts: false
>   become: yes
>   tasks:
> - name: mounting the volume in the fstab file
>   mount:
> fstype: nfs
> opts:
> "rw,bg,hard,rsize=65536,wsize=65536,vers=3,actimeo=0,nointr,suid,timeo=600,tcp"
> dump: "0"
> passno: "0"
> src: "{{ var1 }}"
> path: "{{ var2 }}"
> state: mounted
>   delegate_to: "{{ inventory_hostname }}"
> ...
>
>
> 
> Playbook Verbose Output:
>
> 
>
> TASK [reading volume info from csv]
> *
> task path: /suresh/suresh_playbooks/mounts.yml:7
> <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
> <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
> <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532 `" && echo
> ansible-tmp-1586795492.17-47707210108532="` echo
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532 `" ) && sleep 0'
> Using module file
> /usr/lib/python2.7/site-packages/ansible/modules/files/read_csv.py
> <127.0.0.1> PUT /root/.ansible/tmp/ansible-local-26007iAx4cI/tmpxiOrdU TO
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/AnsiballZ_read_csv.py
> <127.0.0.1> EXEC /bin/sh -c 'chmod u+x
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/AnsiballZ_read_csv.py
> && sleep 0'
> <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/AnsiballZ_read_csv.py
> && sleep 0'
> <127.0.0.1> EXEC /bin/sh -c 'rm -f -r
> /root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/ > /dev/null
> 2>&1 && sleep 0'
> ok: [localhost] => {
> "changed": false,
> "dict": {},
> "invocation": {
> "module_args": {
> "delimiter": null,
> "dialect": "excel",
> "fieldnames": null,
> "key": null,
> "path": "/suresh/suresh_playbooks/mounts.csv",
> "skipinitialspace": null,
> "strict": null,
> "unique": true
> }
> },
> "list": [
> {
> "host": "host1",
> "mnt_path": "/myasup/stg/data",
> "python": "/usr/bin/python2.6",
> "remote_path": "nfsflr01:/volahcstg_www_masup_stg_data_01"
> },
> {
> "host": "host2",
> "mnt_path": "/myasup/stg/data",
> "python": "/usr/bin/python2.6",
> "remote_path": "nfsflr01:/volahcstg_www_masup_stg_data_01"
> }
> ]
> }
>
> TASK [Grouping host and volume information]
> *
> task path: /suresh/suresh_playbooks/mounts.yml:11
> creating host via 'add_host': hostname=host1
> changed: [localhost] => (item=[u'host1', [{u'python':
> u'/usr/bin/python2.6', u'host': u'host1', u'mnt_path': u'/myasup/stg/data',
> 

[ansible-project] Re: Need Assistance With Ansible Error

2020-04-14 Thread Orkhan Mammadov
Run the file from the directory, where your config file is located.

On Wednesday, April 15, 2020 at 7:46:36 AM UTC+4, George James wrote:
>
> I am new to ansible.
>
> I create an inventory file 
>
> [web] 
> 167.172.xxx.xxx ansible_connection=ssh ansible_user=root 
> ansible_ssh_private_key_file=~/.ssh/id_rsa.pub
>
> Then I run 
>
> ansible web -m ping -i hosts -
>
> But I am presented with the following log and error
>
>
> ansible 2.9.6
>   config file = None
>   configured module search path = ['/Users/g.james/.ansible/plugins/modules', 
> '/usr/share/ansible/plugins/modules']
>   ansible python module location = 
> /usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible
>   executable location = /usr/local/bin/ansible
>   python version = 3.8.2 (default, Mar 11 2020, 00:29:50) [Clang 11.0.0 
> (clang-1100.0.33.17)]
> No config file found; using defaults
> setting up inventory plugins
> host_list declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as 
> it did not pass its verify_file() method
> script declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it 
> did not pass its verify_file() method
> auto declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it 
> did not pass its verify_file() method
> Parsed /Users/g.james/dojo360/d3-scripts/server/hosts inventory source with 
> ini plugin
> Loading callback plugin minimal of type stdout, v2.0 from 
> /usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible/plugins/callback/minimal.py
> META: ran handlers
> <67.172.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
> <67.172.xxx.xxx> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
> ControlPersist=60s -o 'IdentityFile="/Users/g.james/.ssh/id_rsa.pub"' -o 
> KbdInteractiveAuthentication=no -o 
> PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
> PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 
> ControlPath=/Users/g.james/.ansible/cp/5d3d6b8351 67.172.xxx.xxx '/bin/sh -c 
> '"'"'echo ~root && sleep 0'"'"''
> <67.172.xxx.xxx> (255, b'', b'OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: 
> Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config 
> line 48: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 
> 67.172.xxx.xxx is address\r\ndebug1: auto-mux: Trying existing 
> master\r\ndebug1: Control socket "/Users/g.james/.ansible/cp/5d3d6b8351" does 
> not exist\r\ndebug2: ssh_connect_direct\r\ndebug1: Connecting to 
> 67.172.xxx.xxx [67.172.xxx.xxx] port 22.\r\ndebug2: fd 3 setting 
> O_NONBLOCK\r\ndebug1: connect to address 67.172.xxx.xxx port 22: Operation 
> timed out\r\nssh: connect to host 67.172.xxx.xxx port 22: Operation timed 
> out\r\n')
> 67.172.xxx.xxx | UNREACHABLE! => {
> "changed": false,
> "msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1, LibreSSL 
> 2.7.3\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
> /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: 
> resolve_canonicalize: hostname 67.172.xxx.xxx is address\r\ndebug1: auto-mux: 
> Trying existing master\r\ndebug1: Control socket 
> \"/Users/g.james/.ansible/cp/5d3d6b8351\" does not exist\r\ndebug2: 
> ssh_connect_direct\r\ndebug1: Connecting to 67.172.xxx.xxx [67.172.xxx.xxx] 
> port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: connect to address 
> 67.172.xxx.xxx port 22: Operation timed out\r\nssh: connect to host 
> 67.172.xxx.xxx port 22: Operation timed out",
> "unreachable": true
> }
>
> Please I need help, I have been stuck on this for 48 hours, tried different 
> computers  and VMs all returns back the same result
>
>

-- 
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/b3197ac7-0e43-4d50-bc4a-4be55b772968%40googlegroups.com.


[ansible-project] fatal: [127.0.0.1 -> localhost]: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n"

2020-04-14 Thread HAMDAN Khalil
Hello,

I need your help
When I execute my ansible command directly "ansible-playbook playbook.yml -i 
hosts" without going through jenkins I  have no problem 

ubuntu@ip-172-31-40-178:/var/lib/jenkins/workspace/SI-AFD$ ansible-playbook 
playbook.yml -i hosts

PLAY [[LOCAL DEPLOYMENT]] 
**

TASK [Clean tmp directory] 
*
[WARNING]: Consider using 'become', 'become_method', and 'become_user' rather 
than running sudo
changed: [127.0.0.1 -> localhost]

TASK [Get updated files from AFD git repository] 
***
changed: [127.0.0.1]


but when I go through jenkins I have this error:

[Pipeline] }[Pipeline] // stage[Pipeline] stage 
[Pipeline] { (Deploiement Ansible) 
[Pipeline] sh 
+ ansible-playbook playbook.yml -i 
hosts

PLAY [[LOCAL DEPLOYMENT]] **

TASK [Clean tmp directory] *
fatal: [127.0.0.1 -> localhost]: FAILED! => {"changed": false, "module_stderr": 
"sudo: a password is required\n", "module_stdout": "", "msg": "MODULE 
FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

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


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7c4b57bf-738a-4fe0-a667-9c958e5ed4ca%40googlegroups.com.


[ansible-project] Need Assistance With Ansible Error

2020-04-14 Thread George James
I am new to ansible.

I create an inventory file 

[web] 
167.172.xxx.xxx ansible_connection=ssh ansible_user=root 
ansible_ssh_private_key_file=~/.ssh/id_rsa.pub

Then I run 

ansible web -m ping -i hosts -

But I am presented with the following log and error


ansible 2.9.6
  config file = None
  configured module search path = ['/Users/g.james/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = 
/usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.2 (default, Mar 11 2020, 00:29:50) [Clang 11.0.0 
(clang-1100.0.33.17)]
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it 
did not pass its verify_file() method
script declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it 
did not pass its verify_file() method
auto declined parsing /Users/g.james/dojo360/d3-scripts/server/hosts as it did 
not pass its verify_file() method
Parsed /Users/g.james/dojo360/d3-scripts/server/hosts inventory source with ini 
plugin
Loading callback plugin minimal of type stdout, v2.0 from 
/usr/local/Cellar/ansible/2.9.6_1/libexec/lib/python3.8/site-packages/ansible/plugins/callback/minimal.py
META: ran handlers
<67.172.xxx.xxx> ESTABLISH SSH CONNECTION FOR USER: root
<67.172.xxx.xxx> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o 'IdentityFile="/Users/g.james/.ssh/id_rsa.pub"' -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o 
PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 
ControlPath=/Users/g.james/.ansible/cp/5d3d6b8351 67.172.xxx.xxx '/bin/sh -c 
'"'"'echo ~root && sleep 0'"'"''
<67.172.xxx.xxx> (255, b'', b'OpenSSH_7.9p1, LibreSSL 2.7.3\r\ndebug1: Reading 
configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: 
Applying options for *\r\ndebug2: resolve_canonicalize: hostname 67.172.xxx.xxx 
is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control 
socket "/Users/g.james/.ansible/cp/5d3d6b8351" does not exist\r\ndebug2: 
ssh_connect_direct\r\ndebug1: Connecting to 67.172.xxx.xxx [67.172.xxx.xxx] 
port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: connect to address 
67.172.xxx.xxx port 22: Operation timed out\r\nssh: connect to host 
67.172.xxx.xxx port 22: Operation timed out\r\n')
67.172.xxx.xxx | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1, LibreSSL 
2.7.3\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
/etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: 
resolve_canonicalize: hostname 67.172.xxx.xxx is address\r\ndebug1: auto-mux: 
Trying existing master\r\ndebug1: Control socket 
\"/Users/g.james/.ansible/cp/5d3d6b8351\" does not exist\r\ndebug2: 
ssh_connect_direct\r\ndebug1: Connecting to 67.172.xxx.xxx [67.172.xxx.xxx] 
port 22.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: connect to address 
67.172.xxx.xxx port 22: Operation timed out\r\nssh: connect to host 
67.172.xxx.xxx port 22: Operation timed out",
"unreachable": true
}

Please I need help, I have been stuck on this for 48 hours, tried different 
computers  and VMs all returns back the same result

-- 
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/4eb61578-efb6-4d3a-a07b-8318b8d165f3%40googlegroups.com.


[ansible-project] Help with a Windows target node

2020-04-14 Thread NoobSkywalker
The user under which I'm running Ansible is not a user on the target node ... 
but the user I've identified in test.yaml is a user on thae target node, and is 
a member of the local Administrators group.

Thanks for trying to help, appreciate 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/d3dcd876-1c45-4072-a2a3-f927698ee4c3%40googlegroups.com.


Re: [ansible-project] Login/Password encryption in host file

2020-04-14 Thread David Foley

You could use vault / hash or shadow your password and use that hashed value. 
Or you could add you job to a CI/CD pipeline add your credentials into that 
pipeline which will be hashed out on Stdout

-- 
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/d4e726a7-c2c9-4009-b4da-7f9e5b889b0f%40googlegroups.com.


[ansible-project] Help with a Windows target node

2020-04-14 Thread David Foley
Is the user part of the local Admin group or has access to login to the machine 

-- 
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/320c80d3-ab20-4ddc-a3fa-12ca3e668124%40googlegroups.com.


[ansible-project] Send data from Google Compute Engine to Google Pub/Sub using Ansible

2020-04-14 Thread 'Jam Volkov' via Ansible Project


I would like to send data from Google vm instance to Google Pub/Sub using 
Ansible.
Ansible playbook

--- 
- hosts: localhost 
  tasks: 
  
  - name: Write into log file 
local_action: 
  shell echo "Hello" >> /etc/ansible/log.txt 

  - name: Send message through pubsub 
shell: python pub.py project-344421 topic_test 
args: 
  chdir: /home/pubsub 

Error

"msg": "non-zero return code", 
"rc": 1, 
"start": "2020-04-14 18:20:00.723265", 
"stderr": "Traceback (most recent call last):\n  File \"pub.py\", line 22, 
in \nfrom google.cloud import pubsub_v1\nImportError: No module 
named google.cloud", 
"stderr_lines": [
"Traceback (most recent call last):", 
"  File \"pub.py\", line 22, in ", 
"from google.cloud import pubsub_v1", 
"ImportError: No module named google.cloud"
], 
"stdout": "", 
"stdout_lines": []


 Manually, the script pub.py runs properly with python pub.py 
project-344421 topic_test

 Output

der_topic
Published message Hello
 now has message ID 874436722336138
Published 1 message(s).


The modules google.cloud, google-cloud-pubsub and google-auth are installed

pip install --upgrade google-cloud
pip install --upgrade google-cloud-pubsub
pip install --upgrade google-auth 



-- 
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/f248bc4f-4712-40a6-a5c6-71de23b71921%40googlegroups.com.


[ansible-project] Help with a Windows target node

2020-04-14 Thread NoobSkywalker
-
Ansible control node:  CentOS Linux release 8.1.1911 (Core)
-
Ansible version:
*ansible 2.9.5*
  config file = /local1/cnxbuild/ansible/ansible.cfg
  configured module search path = 
['/usr/lib/python3.6/site-packages/ansible/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 
20190507 (Red Hat 8.3.1-4)]
-
Ansible target node:  Windows 2019 Datacenter 10.0.17763 Build 17763
-
>From the Ansible control node, I'm able to SSH into the target node without 
issue:

[cnxbuild@fakeHost ansible]$ ssh -i /etc/ansible/ansible_private_key 
cnxbu...@xxx.xxx.xxx.xxx
FIPS mode initialized

Microsoft Windows [Version 10.0.17763.1131]

   
(c) 2018 Microsoft Corporation. All rights reserved.

 
cnxbuild@FAKEHOST C:\Users\cnxbuild>hostname

   
fakeHost
-
Command running from the control node:

*ansible-playbook - test.yaml -i fakeHost.fake.domain.com,*
-
Contents of test.yaml:

*---*

*- hosts: fakeHost.fake.domain.com*
*  #remote_user: cnxbuild*
*  remote_user: **fakeHost**\cnxbuild*
*  #remote_user: **fakeHost**\Administrator*
*  #remote_user: **fakeHost**\\cnxbuild*

*  tasks:*
*- name: Save the result of 'whoami' in 'whoami_out'*
*  win_command: whoami*
*  register: whoami_out*
 
-

Output below shows that the connection to the Windows node's OpenSSH server 
was successful, but the Ansible command fails ... any insight would be 
greatly appreciated:

[cnxbuild@fakeHost ansible]$ *ansible-playbook - test.yaml -i 
fakeHost.fake.domainName,*
ansible-playbook 2.9.5
  config file = /local1/cnxbuild/ansible/ansible.cfg
  configured module search path = 
['/usr/lib/python3.6/site-packages/ansible/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 
20190507 (Red Hat 8.3.1-4)]
Using /local1/cnxbuild/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed fakeHost.fake.domainName, inventory source with host_list plugin
Loading callback plugin default of type stdout, v2.0 from 
/usr/lib/python3.6/site-packages/ansible/plugins/callback/default.py

PLAYBOOK: test.yaml 
**
Positional arguments: test.yaml
verbosity: 4
private_key_file: /etc/ansible/ansible_private_key
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('fakeHost.fake.domainName,',)
forks: 5
1 plays in test.yaml

PLAY [fakeHost.fake.domainName] 
***

TASK [Gathering Facts] 
***
task path: /local1/cnxbuild/ansible/test.yaml:4
 ESTABLISH SSH CONNECTION FOR USER: 
fakeHost\cnxbuild
 SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o 
ControlPersist=60s -o 'IdentityFile="/etc/ansible/ansible_private_key"' -o 
KbdInteractiveAuthentication=no -o 
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey 
-o PasswordAuthentication=no -o 'User="fakeHost\cnxbuild"' -o 
ConnectTimeout=10 -o ControlPath=/home/cnxbuild/.ansible/cp/901ffc4105 
fakeHost.fake.domainName 'powershell.exe -c '"'"'( umask 77 && mkdir -p "` 
echo C:/Users/cnxbuild/ansible-tmp-1586885382.8679295-215601829120425 `" && 
echo ansible-tmp-1586885382.8679295-215601829120425="` echo 

[ansible-project] Ansible mattermost custom icon_url

2020-04-14 Thread Michael
According to the Ansible mattermost module documentation 
; 
the mattermost message sender's icon is a url that defaults to the redhat 
icon. It can be customized but a url to the to the image needed should be 
provided. 

I didn't think this made sense but i'm hoping that i can find some helpful 
explanation as to how i can use my custom emoji :loudspeaker: without 
having to upload any images to anywhere and define permissions to the image.

Example from the Ansible website:

- name: Send notification message via Mattermost all options
  mattermost:
url: http://mattermost.example.com
api_key: my_api_key
text: '{{ inventory_hostname }} completed'
channel: notifications
username: 'Ansible on {{ inventory_hostname }}'
icon_url: http://www.example.com/some-image-file.png


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/6fa9fb17-37a7-4d0d-96af-927c70a60a43%40googlegroups.com.


[ansible-project] Ansible With_Item as Variable

2020-04-14 Thread David Foley
Hi All,

Could do with some Help with this issue:

I am trying to get the Powerstate of a Virtual Machine and power off when 
powerstate != poweroff
and looking at a way to copy the copy the Cluster variable to a Text File:

---
- name: Running Create Virtual Machine Playbook
  hosts: localhost
  gather_facts: false
  connection: local
  tasks:
  - name: Getting Info from Virtual Machine
vmware_vm_info:
  validate_certs: no
  hostname: "{{ vcenter }}"
  username: "{{ user }}"
  password: "{{ password }}"
  folder: "/"
delegate_to: localhost
register: vminfo
  - debug:
  msg: "{{ item.power_state }}"
with_items:
  - "{{ vm_info.virtual_machines | json_query(query) }}"
vars:
  query: "[?guest_name=='win201_old']"
  
   - vmware_guest_powerstate:
   validate_certs: no
   hostname: "{{ vcenter }}"
   username: "{{ user }}"
   password: "{{ password }}"
   name: win201_old
   state: powered-off
 delegate_to: localhost
 when: "{{ item.power_state }}" != "poweredOff"

   - name: Copy Variable
 copy:
  content: '{{ item.cluster }}'
  dest: /srv/ansible/test.txt 
   delegate_to: localhost

-- 
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/5a5cc162-6dea-4af5-b5a9-af061ab8a1a0%40googlegroups.com.


Re: [ansible-project] Re: need assistance with this playbook

2020-04-14 Thread Abhijeet Kasurde
vmware_host_active_directory does not have a parameter called 'ad_username'
its actually 'ad_user'

On Tue, Apr 14, 2020 at 9:14 PM Tony Wong  wrote:

> Hi
>
> Am I not allowed to have multiple modules in same yml file?
>
> ---
> # Add a ESXi Host to a Datacenter using the 'vmware_host' module
> - name: Join ESXi host to AD
>   vmware_host_active_directory:
> hostname: '{{ vcenter_hostname }}'
> username: '{{ vcenter_username }}'
> password: '{{ vcenter_password }}'
> esxi_hostname: '{{ esxi_hostname }}'
> ad_domain: domain.com
> ad_username: u...@domain.com
> ad_password: xx
> ad_state: present
> validate_certs: no
>   delegate_to: localhost
>
> - name: Set NTP servers for an ESXi Host
>   vmware_host_ntp:
> hostname: '{{ vcenter_hostname }}'
> username: '{{ vcenter_username }}'
> password: '{{ vcenter_password }}'
> esxi_hostname: '{{ esxi_hostname }}'
> state: present
> ntp_servers:
> - 0.pool.ntp.org
> - 1.pool.ntp.org
>   delegate_to: localhost
>
> - name: Manage multiple settings for an ESXi host
>   vmware_host_config_manager:
> hostname: '{{ vcenter_hostname }}'
> username: '{{ vcenter_username }}'
> password: '{{ vcenter_password }}'
> esxi_hostname: '{{ esxi_hostname }}'
> options:
> 'VMkernel.Boot.hyperthreadingMitigation': true
>   delegate_to: localhost
>
>
>
> when i run my playbook it gives this
>
>
>
>
> On Tue, Apr 14, 2020 at 8:30 AM David Foley  wrote:
>
>> Hi Tony:
>>
>> I think you need to look at powercli for ESXi Configuration:
>>
>> On Tuesday, April 14, 2020 at 2:28:33 PM UTC+1, Tony Wong wrote:
>>>
>>> how do i create a ansible vmware playbook with following
>>>
>>>
>>> - join esx host to domain
>>> - setup ntp with - 0.pool.ntp.org, 1.pool.ntp.org
>>> - set advance settings on host : VMkernel.Boot.hyperthreadingMitigation
>>> to True
>>> - reboot host
>>>
>>>
>>>
>>> --
>> 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/620e0b8b-728a-4e63-af4b-72b12b7fbe8d%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/CALmkhkrkiyhFfFdYGnnNPeH2x1bLKmMk2Y_EDojFyWE2Q3Gu%3DQ%40mail.gmail.com
> 
> .
>


-- 
Thanks,
Abhijeet Kasurde

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


[ansible-project] Re: need assistance with this playbook

2020-04-14 Thread David Foley
Hi Tony:

I think you need to look at powercli for ESXi Configuration: 

On Tuesday, April 14, 2020 at 2:28:33 PM UTC+1, Tony Wong wrote:
>
> how do i create a ansible vmware playbook with following
>
>
> - join esx host to domain
> - setup ntp with - 0.pool.ntp.org, 1.pool.ntp.org
> - set advance settings on host : VMkernel.Boot.hyperthreadingMitigation 
> to True
> - reboot host
>
>
>
>

-- 
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/620e0b8b-728a-4e63-af4b-72b12b7fbe8d%40googlegroups.com.


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

2020-04-14 Thread Suresh Karpurapu
Hi Vladimir, thanks for your help all the time.

I tried using the logic, and it worked when apply the values to debug but
the same data is passing to mount module with additional quotes and
brackets which is causing the errors. Any suggestions please?

Playbook and CSV details:
=

# cat mounts.csv
host,remote_path,mnt_path,python
host1,nfsflr01:/volahcstg_www_masup_stg_data_01,/myasup/stg/data,/usr/bin/python2.6
host2,nfsflr01:/volahcstg_www_masup_stg_data_01,/myasup/stg/data,/usr/bin/python2.6
# 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
- name: Grouping host and volume information
  add_host:
name: "{{ item.0 }}"
groups: nfsgroup
var1: "{{ item.1|json_query('[].remote_path') }}"
var2: "{{ item.1|json_query('[].mnt_path') }}"
ansible_python_interpreter: "{{ item.1.0.python }}"
  loop: "{{ sources.list|groupby('host') }}"
- name: list the volumes
  hosts: nfsgroup
  become: yes
  gather_facts: false
  tasks:
- name: debug output
  debug:
msg:
  - "{{ inventory_hostname }}"
  - "{{ var1 }}"
  - "{{ var2 }}"
- name: mounting the volume in the fstab file
  hosts: nfsgroup
  gather_facts: false
  become: yes
  tasks:
- name: mounting the volume in the fstab file
  mount:
fstype: nfs
opts:
"rw,bg,hard,rsize=65536,wsize=65536,vers=3,actimeo=0,nointr,suid,timeo=600,tcp"
dump: "0"
passno: "0"
src: "{{ var1 }}"
path: "{{ var2 }}"
state: mounted
  delegate_to: "{{ inventory_hostname }}"
...


Playbook Verbose Output:


TASK [reading volume info from csv]
*
task path: /suresh/suresh_playbooks/mounts.yml:7
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532 `" && echo
ansible-tmp-1586795492.17-47707210108532="` echo
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532 `" ) && sleep 0'
Using module file
/usr/lib/python2.7/site-packages/ansible/modules/files/read_csv.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-26007iAx4cI/tmpxiOrdU TO
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/AnsiballZ_read_csv.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/AnsiballZ_read_csv.py
&& sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/AnsiballZ_read_csv.py
&& sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r
/root/.ansible/tmp/ansible-tmp-1586795492.17-47707210108532/ > /dev/null
2>&1 && sleep 0'
ok: [localhost] => {
"changed": false,
"dict": {},
"invocation": {
"module_args": {
"delimiter": null,
"dialect": "excel",
"fieldnames": null,
"key": null,
"path": "/suresh/suresh_playbooks/mounts.csv",
"skipinitialspace": null,
"strict": null,
"unique": true
}
},
"list": [
{
"host": "host1",
"mnt_path": "/myasup/stg/data",
"python": "/usr/bin/python2.6",
"remote_path": "nfsflr01:/volahcstg_www_masup_stg_data_01"
},
{
"host": "host2",
"mnt_path": "/myasup/stg/data",
"python": "/usr/bin/python2.6",
"remote_path": "nfsflr01:/volahcstg_www_masup_stg_data_01"
}
]
}

TASK [Grouping host and volume information]
*
task path: /suresh/suresh_playbooks/mounts.yml:11
creating host via 'add_host': hostname=host1
changed: [localhost] => (item=[u'host1', [{u'python':
u'/usr/bin/python2.6', u'host': u'host1', u'mnt_path': u'/myasup/stg/data',
u'remote_path': u'nfsflr01:/volahcstg_www_masup_stg_data_01'}]]) => {
"add_host": {
"groups": [
"nfsgroup"
],
"host_name": "host1",
"host_vars": {
"ansible_python_interpreter": "/usr/bin/python2.6",
"var1": [
"nfsflr01:/volahcstg_www_masup_stg_data_01"
],

[ansible-project] Need help regarding Ansible Role/Playbooks documentation

2020-04-14 Thread Rahul Kumar
Hi Ansible Gurus,
I have many Ansible Roles and I want to document each and every variable of
role with defaults values and their description and where they make sense?

Is there any better way of Documenting Ansible variables because in case
roles have many variables it becomes very difficult for some one to
document them manually in doc or pdf !

Regards
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/CAGH8rExZTbMUCB2GHRZNR4p3%3DXrQfTXhPfNk2kRpVt9_Av%2B8%3DA%40mail.gmail.com.


Re: [ansible-project] need assistance with this playbook

2020-04-14 Thread Jorge Rúa
Have a look here https://github.com/veksh/ansible-esxi

El mar., 14 abr. 2020 a las 14:28, Tony Wong ()
escribió:

> how do i create a ansible vmware playbook with following
>
>
> - join esx host to domain
> - setup ntp with - 0.pool.ntp.org, 1.pool.ntp.org
> - set advance settings on host : VMkernel.Boot.hyperthreadingMitigation
> to True
> - reboot host
>
>
>
> --
> 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/f2c4baa1-fa5f-4895-a67e-3d95c318a89e%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/CAFtje5PK4ZP5CgsPK10zuhYhY0g%3D%3D6rsk8S%2B6N9zWh%3DnY8Am_A%40mail.gmail.com.


[ansible-project] need assistance with this playbook

2020-04-14 Thread Tony Wong
how do i create a ansible vmware playbook with following


- join esx host to domain
- setup ntp with - 0.pool.ntp.org, 1.pool.ntp.org
- set advance settings on host : VMkernel.Boot.hyperthreadingMitigation to 
True
- reboot host



-- 
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/f2c4baa1-fa5f-4895-a67e-3d95c318a89e%40googlegroups.com.


Re: [ansible-project] Login/Password encryption in host file

2020-04-14 Thread Ankit Vashistha
Ansible Documentation is a wonderful place. Did you try searching for the
solution? Try the following doc, it has got all the scenarios.
https://docs.ansible.com/ansible/latest/user_guide/vault.html

You can use group vars directory and create yml files with group names with
encrypted credential values.

*Regards,*
*Ankit*


On Tue, Apr 7, 2020 at 1:34 AM Ashish Sagar 
wrote:

> Hi,
>
> Is there anyway to only encrypt Device login/password credentials in hosts
> file ? If so, Where should encryption key be saved and how to use it for
> decrypt ?
>
> Thanks in Advace.
>
> -Ashish
>
> --
> 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/CADa6Y5bDzerbYB0RW1Cf-2vnw4721RzvZ6YqoOgeg51HUxJL0Q%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/CACecUhv%3DP2zi_4a1q6NAtZxMqyQ7wXxfQLnGUcsKqjNWZYm0AQ%40mail.gmail.com.


Re: [ansible-project] Connecting to Linux and Windows hosts

2020-04-14 Thread Ankit Vashistha
Not sure if i get your question. You can specify the group specific
variables including connection method like below. You need to identify
their OS so that you could specify which host will use which connection
method.

[all:vars]
ansible_connection=ssh
ansible_ssh_user=user
ansible_ssh_pass=user_pass

[host_linux]
192.168.[1:254].[1:3]

[host_linux:vars]
ansible_connection=ssh

[host_windows]
10.10.10.10

[host_windows:vars]
ansible_connection=winrm

*Regards,*
*Ankit*


On Thu, Apr 9, 2020 at 5:33 PM PH  wrote:

> Please, help me to understand, how fill hosts file.
> Now i have linux hosts and it's work's fine.
> Exaple, how host file look's like:
> [all:vars]
> ansible_connection=ssh
> ansible_ssh_user=user
> ansible_ssh_pass=user_pass
> [host_linux]
> 192.168.[1:254].[1:3]
>
> When trying to add windows hosts (ip adresses may be same as linux,
> because hosts about 1000 and i don't know exatly where linux\windows
> installed) with windows vars - all hosts including linux and windows hosts
> began connecting using winrm.
> Host file looks like:
> [host_linux]
> ansible_connection=ssh
> ansible_ssh_user=user
> ansible_ssh_pass=user_pass
> [host_linux]
> 192.168.[1:254].[1:3]
> [host_windows:vars]
> ansible_user=user
> ansible_password=user_pass
> ansible_connection=winrm
> ansible_winrm_server_cert_validation=ignore
> ansible_winrm_transport=basic
> [host_windows]
> 192.168.[1:254].[1:3]
>
> How do I fill in the host file so that Linux hosts run using ssh, Windows
> hosts using winrm.
>
> --
> 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/6c39eaa7-6ddb-4bdd-af09-b201b777ac57%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/CACecUhuB6fZLBRhPACio2yHS9b-ygD%3DRjX4yQstxwO5LiKQx%2BQ%40mail.gmail.com.


Re: [ansible-project] [HOSTVARS][MERGED] Unexpected behavior with merge variables of different host which are in several groups

2020-04-14 Thread Jean-Yves LENHOF

Hi,

As I understand etc_ip and postgresql_ip are variable specific for each 
host, and so they should be in hosts parts of your inventory file (Here 
you are doing a mix).


postgresql_existscan be setup in a your postgresql group, but I'm not 
sure if it is really necessary to have it


See there for example : 
https://docs.ansible.com/ansible/latest/plugins/inventory/yaml.html


If you want further help, please provide your playbooks used for your 
outputs.


And for the record, no needs to use a playbook to list variables, 
command "ansible-inventory" can be used successfully for this


Regards,

Le 14/04/2020 à 11:39, Baptiste Doublet a écrit :

Hi Everybody,

I have a problem that I can't resolve on my own.
I want to deploy an etcd cluster with postgresql on the same servers
I have three servers and this is my inventory file:

```
all:
children:
etcd_cluster: # recommendation: 3 or 5-7 nodes
hosts:
demo_postgres1:
vars:
etcd_ip: '***'
demo_postgres2:
vars:
etcd_ip: '***'
demo_postgres3:
vars:
etcd_ip: '***'
master:
hosts:
demo_postgres1:
vars:
postgres_ip: '***'
postgresql_exists: 'false'
replica:
hosts:
demo_postgres2:
vars:
postgres_ip: '***'
postgresql_exists: 'false'
demo_postgres3:
vars:
postgres_ip: '***'
postgresql_exists: 'false'
balancers:
hosts:
demo_haproxy1:
vars:
haproxy_ip: '***'
demo_haproxy2:
vars:
haproxy_ip: '***'
demo:
vars:
ansible_ssh_common_args: "-F ../../ssh_config/demo_config"
children:
balancers:
etcd_cluster:
postgres_cluster:
children:
master:
replica:
```
I have the demo_postgres[0-3] servers that run etcd and postgres. Just 
to prepare an external instance for etcd cluster, I have separated its 
in two distinct groups: etcd_cluster and postgres_cluster.

I have etcd_ip vars and postgres_ip varsrespectivelyon these groups.

My problem is when I run my playbook with hosts: etcd_cluster and I 
print hostvars, I get the hostvars of postgres_cluster:


```
PLAY [etcd_cluster] 
***


TASK [Gathering Facts] 


ok: [demo_postgres1]
ok: [demo_postgres3]
ok: [demo_postgres2]

TASK [Ansible | List all known variables and facts] 
***

ok: [demo_postgres1] => {
    "hostvars[inventory_hostname]['vars']": {
    "postgres_ip": "***",
    "postgresql_exists": "false"
    }
}
ok: [demo_postgres2] => {
    "hostvars[inventory_hostname]['vars']": {
    "postgres_ip": "***",
    "postgresql_exists": "false"
    }
}
ok: [demo_postgres3] => {
    "hostvars[inventory_hostname]['vars']": {
    "postgres_ip": "***",
    "postgresql_exists": "false"
    }
}

```
I didn't find any information about the merging of hostvars when the 
host is in multiple groups and when I have tested to remove the 
postgres_cluster group, I get the correct hostvars:


```
PLAY [etcd_cluster] 
***


TASK [Gathering Facts] 


ok: [demo_postgres1]
ok: [demo_postgres3]
ok: [demo_postgres2]

TASK [Ansible | List all known variables and facts] 
***

ok: [demo_postgres1] => {
    "hostvars[inventory_hostname]['vars']": {
    "etcd_ip": "***"
    }
}
ok: [demo_postgres2] => {
    "hostvars[inventory_hostname]['vars']": {
    "etcd_ip": "***"
    }
}
ok: [demo_postgres3] => {
    "hostvars[inventory_hostname]['vars']": {
    "etcd_ip": "***"
    }
}
```

I would expect that my etcd_ip was merged with postgres_ip ? I can 
resolve this by adding the etcd_ip in postgres_cluster hostvars but I 
want to understand why merge is not working.


If you need more information, feel free to ask.

Best regards,

BDO
--
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/d674a6d6-6640-4abb-ba52-51a5f2369692%40googlegroups.com 

[ansible-project] [HOSTVARS][MERGED] Unexpected behavior with merge variables of different host which are in several groups

2020-04-14 Thread Baptiste Doublet
Hi Everybody,

I have a problem that I can't resolve on my own.
I want to deploy an etcd cluster with postgresql on the same servers
I have three servers and this is my inventory file:

```
all:
children:
etcd_cluster: # recommendation: 3 or 5-7 nodes
hosts:
demo_postgres1:
vars:
etcd_ip: '***'
demo_postgres2:
vars:
etcd_ip: '***'
demo_postgres3:
vars:
etcd_ip: '***'
master:
hosts:
demo_postgres1:
vars:
postgres_ip: '***'
postgresql_exists: 'false'
replica:
hosts:
demo_postgres2:
vars:
postgres_ip: '***'
postgresql_exists: 'false'
demo_postgres3:
vars:
postgres_ip: '***'
postgresql_exists: 'false'
balancers:
hosts:
demo_haproxy1:
vars:
haproxy_ip: '***'
demo_haproxy2:
vars:
haproxy_ip: '***'
demo:
vars:
ansible_ssh_common_args: "-F ../../ssh_config/demo_config"
children:
balancers:
etcd_cluster: 
postgres_cluster:
children:
master:
replica:
```
I have the demo_postgres[0-3] servers that run etcd and postgres. Just to 
prepare an external instance for etcd cluster, I have separated its in two 
distinct groups: etcd_cluster and postgres_cluster.
I have etcd_ip vars and postgres_ip vars respectively on these groups.

My problem is when I run my playbook with hosts: etcd_cluster and I print 
hostvars, I get the hostvars of postgres_cluster:

```
PLAY [etcd_cluster] 
***

TASK [Gathering Facts] 

ok: [demo_postgres1]
ok: [demo_postgres3]
ok: [demo_postgres2]

TASK [Ansible | List all known variables and facts] 
***
ok: [demo_postgres1] => {
"hostvars[inventory_hostname]['vars']": {
"postgres_ip": "***",
"postgresql_exists": "false"
}
}
ok: [demo_postgres2] => {
"hostvars[inventory_hostname]['vars']": {
"postgres_ip": "***",
"postgresql_exists": "false"
}
}
ok: [demo_postgres3] => {
"hostvars[inventory_hostname]['vars']": {
"postgres_ip": "***",
"postgresql_exists": "false"
}
}

```
I didn't find any information about the merging of hostvars when the host 
is in multiple groups and when I have tested to remove the postgres_cluster 
group, I get the correct hostvars:

```
PLAY [etcd_cluster] 
***

TASK [Gathering Facts] 

ok: [demo_postgres1]
ok: [demo_postgres3]
ok: [demo_postgres2]

TASK [Ansible | List all known variables and facts] 
***
ok: [demo_postgres1] => {
"hostvars[inventory_hostname]['vars']": {
"etcd_ip": "***"
}
}
ok: [demo_postgres2] => {
"hostvars[inventory_hostname]['vars']": {
"etcd_ip": "***"
}
}
ok: [demo_postgres3] => {
"hostvars[inventory_hostname]['vars']": {
"etcd_ip": "***"
}
}
```

I would expect that my etcd_ip was merged with postgres_ip ? I can resolve 
this by adding the etcd_ip in postgres_cluster hostvars but I want to 
understand why merge is not working.

If you need more information, feel free to ask.

Best regards,

BDO

-- 
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/d674a6d6-6640-4abb-ba52-51a5f2369692%40googlegroups.com.


Re: [ansible-project] Re: Need some suggestion

2020-04-14 Thread Dick Visser
On Tue, 14 Apr 2020 at 07:08, Rahul Kumar  wrote:
>
> Guys any help on this ?

Not yet apparently, but given that this list is run by volunteers and
it's Easter holidays that shouldn't come as a surprise.

-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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/CAL8fbwNiwJ5UwBrPdgBZN04LS%2BtBgJAesv6kNmwupW_KbBapFA%40mail.gmail.com.