[ansible-project] Re: Windows service recovery on failure with ansible?

2020-05-07 Thread Jordan Borean
It was added witht he PR 
https://github.com/ansible-collections/ansible.windows/pull/40 which is the 
'win_service' module in the ansible.windows collection. This collection is 
officially meant to be the source of supported Windows module in Ansible 
2.10 and onwards but you might be able to use it for Ansible 2.9.

Thanks

Jordan

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/25c725fd-041a-487a-9f83-167d0642a5f2%40googlegroups.com.


Re: [ansible-project] Create user with ssh key, error deploying key

2020-05-07 Thread Dick Visser
parsekey
IndexError: list index out of range


Pretty much says it - something is wrong with the pubkey, in the sense
that the authorized_key module can parse it (see
modules/system/authorized_key.py).
LIkely something with the options of the pubkey, their quoting, or
something with comments (#)?

What does your pubkey look like?



On Fri, 8 May 2020 at 00:27, Michael Mullay  wrote:
>
> Perhaps your ssh key file is somehow malformed? What happens if you go 
> old-school and use ssh-copy-id to try to copy over the key file that way? At 
> least you'll know if it's a problem with your key or the playbook (and if it 
> works with ssh-copy-id of course you can just delete it off the target host 
> when you are ready to retry with your ansible playbook).
>
>
> On Thu, May 7, 2020 at 1:48 PM Joe G  wrote:

 I appreciate the suggestion though I don't believe that is the solution to 
 my problem, right? I suppose I should have posted the actual playbook I'm 
 working with. The one previously provided was just a test one.
>>
>>
>> Here's the task yml file within the role
>>
>> - include_vars: users.yml
>> - name: Create Users On VMs
>>   user: name="{{ item.username }}"
>>   with_items: "{{ users }}"
>>   #shell: /bin/bash
>>   #groups:
>>
>> - name: Add .ssh Keys and Directories
>>   authorized_key: >
>> user="{{item.username}}"
>> key="{{ lookup('file', './files/{{ item.username}}_id_rsa.pub')}}"
>>   with_items: "{{ users }}"
>>
>>  Error
>> failed: [test.preprod.io] (item={u'username': u'joe'}) => {
>> "changed": false,
>> "item": {
>> "username": "joe"
>> },
>> "module_stderr": "OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2u  20 Dec 
>> 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: 
>> /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: 
>> Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: 
>> mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
>> request forwardings: 0 local, 0 remote\r\ndebug3: 
>> mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
>> entering\r\ndebug3: mux_client_request_alive: done pid = 22809\r\ndebug3: 
>> mux_client_request_session: session request sent\r\ndebug1: 
>> mux_client_request_session: master session id: 2\r\nTraceback (most recent 
>> call last):\n  File \"\", line 113, in \n  File \"\", 
>> line 105, in _ansiballz_main\n  File \"\", line 48, in 
>> invoke_module\n  File 
>> \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 678, in 
>> \n  File \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", 
>> line 673, in main\n  File 
>> \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 572, in 
>> enforce_state\n  File 
>> \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 439, in 
>> parsekey\nIndexError: list index out of range\ndebug3: 
>> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
>> exit status from master 1\r\n",
>> "module_stdout": "",
>> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
>> "rc": 1
>> }
>>
>>
>>
>> --
>> 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/d41dc096-c6e8-4fa5-b31b-b495d3e8a4b1%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/CAH4rTPu%2BXsAgNLFBGOASNdaTXre3Dp5DkM4WV8pvRRWgi91SgQ%40mail.gmail.com.



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


Re: [ansible-project] If unreachable - stop giving Failed out and move to next host

2020-05-07 Thread Dick Visser
Out of interest - what is the reason they are unreachable?

On Fri, 8 May 2020 at 00:17, Work-Hard  wrote:
>
> Hi,
> Is it possible for the host that if it's unreachable - stop giving Failed 
> output and move to the next task. As of now, it just shows the output fails.
>
>
> ---
> - hosts: amazonlinux2
>   become: true
>   serial: 1
>   max_fail_percentage: 0
>   ignore_errors: true
>   gather_facts: false
>   ignore_unreachable: true
>   vars:
> ansible_user: ec2-user
>   ignore_errors: yes
>
>
> Output -
>
> fatal: [10.0.2.6]: FAILED! => {"changed": true, "changes": {"installed": [], 
> "updated": [["kernel", "4.14.177-139.253.amzn2.x86_64 from amzn2-core"], 
> ["libwayland-server", "1.17.0-1.amzn2.x86_64 from amzn2-core"], 
> ["http-parser", "2.7.1-8.amzn2.2.x86_64 from amzn2-core"], ["libglvnd-glx", 
> "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], ["python2-rsa", 
> "3.4.1-1.el7.noarch from epel"], ["librsvg2", "2.40.20-1.amzn2.x86_64 from 
> amzn2-core"], ["cairo", "1.15.12-4.amzn2.x86_64 from amzn2-core"], ["libX11", 
> "1.6.7-2.amzn2.x86_64 from amzn2-core"], ["harfbuzz", "1.7.5-2.amzn2.x86_64 
> from amzn2-core"], ["libXrandr", "1.5.1-2.amzn2.0.3.x86_64 from amzn2-core"], 
> ["htop", "2.2.0-3.el7.x86_64 from epel"], ["gdisk", "0.8.10-3.amzn2.x86_64 
> from amzn2-core"], ["perl-Git", "2.23.3-1.amzn2.0.1.noarch from amzn2-core"], 
> ["mesa-libgbm", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["libicu", 
> "50.2-4.amzn2.x86_64 from amzn2-core"], ["git", "2.23.3-1.amzn2.0.1.x86_64 
> from amzn2-core"], ["nagios-common", "4.4.5-7.el7.x86_64 from epel"], 
> ["libglvnd", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], 
> ["python-colorama", "0.3.2-3.el7.noarch from epel"], ["fontconfig", 
> "2.13.0-4.3.amzn2.x86_64 from amzn2-core"], ["microcode_ctl", 
> "2:2.1-47.amzn2.0.6.x86_64 from amzn2-core"], ["pystache", 
> "0.5.3-2.el7.noarch from epel"], ["python2-jsonschema", "2.5.1-4.el7.noarch 
> from epel"], ["sscg", "2.6.1-1.el7.x86_64 from epel"], ["git-core", 
> "2.23.3-1.amzn2.0.1.x86_64 from amzn2-core"], ["python-pillow", 
> "2.0.0-20.gitd1c6db8.amzn2.0.1.x86_64 from amzn2-core"], 
> ["gtk-update-icon-cache", "3.22.30-3.amzn2.x86_64 from amzn2-core"], 
> ["freetype", "2.8-14.amzn2.x86_64 from amzn2-core"], ["avahi-libs", 
> "0.6.31-19.amzn2.0.1.x86_64 from amzn2-core"], ["gdk-pixbuf2", 
> "2.36.12-3.amzn2.x86_64 from amzn2-core"], ["python2-jmespath", 
> "0.9.4-1.el7.noarch from epel"], ["nagios-plugins-nrpe", "4.0.2-1.el7.x86_64 
> from epel"], ["telnet", "1:0.17-65.amzn2.x86_64 from amzn2-core"], 
> ["libglvnd-egl", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], 
> ["libidn2", "2.3.0-1.el7.x86_64 from epel"], ["libdrm", 
> "2.4.97-2.amzn2.x86_64 from amzn2-core"], ["mesa-libEGL", 
> "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["python2-futures", 
> "3.0.5-1.el7.noarch from epel"], ["libwayland-client", "1.17.0-1.amzn2.x86_64 
> from amzn2-core"], ["mesa-libGL", "18.3.4-5.amzn2.0.1.x86_64 from 
> amzn2-core"], ["libX11-common", "1.6.7-2.amzn2.noarch from amzn2-core"], 
> ["pango", "1.42.4-4.amzn2.x86_64 from amzn2-core"], ["kernel-tools", 
> "4.14.177-139.253.amzn2.x86_64 from amzn2-core"], ["kernel-headers", 
> "4.14.177-139.253.amzn2.x86_64 from amzn2-core"], ["pgdg-redhat-repo", 
> "42.0-6.noarch from pgdg94"], ["fribidi", "1.0.2-1.amzn2.1.x86_64 from 
> amzn2-core"], ["nrpe", "4.0.2-1.el7.x86_64 from epel"], ["python-jinja2", 
> "2.8-7.rhel7.noarch from pgdg94"], ["mesa-libglapi", 
> "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["python-repoze-lru", 
> "0.4-3.el7.noarch from epel"], ["nagios-plugins", "2.3.3-2.el7.x86_64 from 
> epel"], ["git-core-doc", "2.23.3-1.amzn2.0.1.noarch from amzn2-core"], 
> ["python-lockfile", "1:0.9.1-4.el7.noarch from epel"], ["yum", 
> "3.4.3-158.amzn2.0.4.noarch from amzn2-core"], ["python-daemon", 
> "1.6-4.el7.noarch from epel"], ["glib2", "2.56.1-5.amzn2.0.1.x86_64 from 
> amzn2-core"], ["php55-php-pear", "1:1.10.12-1.el7.remi.noarch from 
> remi-safe"], ["awscli", "1.16.300-1.amzn2.0.2.noarch from amzn2-core"], 
> ["libmetalink", "0.1.3-1.el7.x86_64 from epel"]]}, "msg": "Error: Package: 
> pgdg-redhat-repo-42.0-6.noarch (pgdg94)\n   Requires: 
> /etc/redhat-release\n", "obsoletes": {"pgdg-centos94": {"dist": "noarch", 
> "repo": "installed", "version": "9.4-3"}}, "rc": 1, "results": ["Loaded 
> plugins: langpacks, update-motd\nResolving Dependencies\n--> Running 
> transaction check\n---> Package avahi-libs.x86_64 0:0.6.31-19.amzn2 will be 
> updated\n---> Package avahi-libs.x86_64 0:0.6.31-19.amzn2.0.1 will be an 
> update\n---> Package awscli.noarch 0:1.16.300-1.amzn2.0.1 will be 
> updated\n---> Package awscli.noarch 0:1.16.300-1.amzn2.0.2 will be an 
> update\n---> Package cairo.x86_64 0:1.14.8-2.amzn2.0.2 will be updated\n---> 
> Package cairo.x86_64 0:1.15.12-4.amzn2 will be an update\n---> Package 
> fontconfig.x86_64 0:2.10.95-11.amzn2.0.2 will be updated\n---> Package 
> fontconfig.x86_64 

Re: [ansible-project] Create user with ssh key, error deploying key

2020-05-07 Thread Michael Mullay
Perhaps your ssh key file is somehow malformed? What happens if you go
old-school and use ssh-copy-id to try to copy over the key file that way?
At least you'll know if it's a problem with your key or the playbook (and
if it works with ssh-copy-id of course you can just delete it off the
target host when you are ready to retry with your ansible playbook).


On Thu, May 7, 2020 at 1:48 PM Joe G  wrote:

> I appreciate the suggestion though I don't believe that is the solution to
>>> my problem, right? I suppose I should have posted the actual playbook I'm
>>> working with. The one previously provided was just a test one.
>>
>>
> Here's the task yml file within the role
>
> - include_vars: users.yml
> - name: Create Users On VMs
>   user: name="{{ item.username }}"
>   with_items: "{{ users }}"
>   #shell: /bin/bash
>   #groups:
>
> - name: Add .ssh Keys and Directories
>   authorized_key: >
> user="{{item.username}}"
> key="{{ lookup('file', './files/{{ item.username}}_id_rsa.pub')}}"
>   with_items: "{{ users }}"
>
>  Error
> failed: [test.preprod.io] (item={u'username': u'joe'}) => {
> "changed": false,
> "item": {
> "username": "joe"
> },
> "module_stderr": "OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2u  20
> Dec 2019\r\ndebug1: Reading configuration data
> /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying
> options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3
> setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version
> 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0
> remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3:
> mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive:
> done pid = 22809\r\ndebug3: mux_client_request_session: session request
> sent\r\ndebug1: mux_client_request_session: master session id:
> 2\r\nTraceback (most recent call last):\n  File \"\", line 113, in
> \n  File \"\", line 105, in _ansiballz_main\n  File
> \"\", line 48, in invoke_module\n  File
> \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 678, in
> \n  File
> \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 673, in
> main\n  File \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\",
> line 572, in enforce_state\n  File
> \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 439, in
> parsekey\nIndexError: list index out of range\ndebug3:
> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received
> exit status from master 1\r\n",
> "module_stdout": "",
> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
> "rc": 1
> }
>
>
>
> --
> 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/d41dc096-c6e8-4fa5-b31b-b495d3e8a4b1%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/CAH4rTPu%2BXsAgNLFBGOASNdaTXre3Dp5DkM4WV8pvRRWgi91SgQ%40mail.gmail.com.


[ansible-project] If unreachable - stop giving Failed out and move to next host

2020-05-07 Thread Work-Hard
Hi,
Is it possible for the host that if it's unreachable - stop giving Failed 
output and move to the next task. As of now, it just shows the output 
fails. 


---
- hosts: amazonlinux2
  become: true
  serial: 1
  max_fail_percentage: 0
  ignore_errors: true
  gather_facts: false
  ignore_unreachable: true
  vars:
ansible_user: ec2-user
  ignore_errors: yes


Output - 

fatal: [10.0.2.6]: FAILED! => {"changed": true, "changes": {"installed": 
[], "updated": [["kernel", "4.14.177-139.253.amzn2.x86_64 from 
amzn2-core"], ["libwayland-server", "1.17.0-1.amzn2.x86_64 from 
amzn2-core"], ["http-parser", "2.7.1-8.amzn2.2.x86_64 from amzn2-core"], 
["libglvnd-glx", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from 
amzn2-core"], ["python2-rsa", "3.4.1-1.el7.noarch from epel"], ["librsvg2", 
"2.40.20-1.amzn2.x86_64 from amzn2-core"], ["cairo", 
"1.15.12-4.amzn2.x86_64 from amzn2-core"], ["libX11", "1.6.7-2.amzn2.x86_64 
from amzn2-core"], ["harfbuzz", "1.7.5-2.amzn2.x86_64 from amzn2-core"], 
["libXrandr", "1.5.1-2.amzn2.0.3.x86_64 from amzn2-core"], ["htop", 
"2.2.0-3.el7.x86_64 from epel"], ["gdisk", "0.8.10-3.amzn2.x86_64 from 
amzn2-core"], ["perl-Git", "2.23.3-1.amzn2.0.1.noarch from amzn2-core"], 
["mesa-libgbm", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["libicu", 
"50.2-4.amzn2.x86_64 from amzn2-core"], ["git", "2.23.3-1.amzn2.0.1.x86_64 
from amzn2-core"], ["nagios-common", "4.4.5-7.el7.x86_64 from epel"], 
["libglvnd", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 from amzn2-core"], 
["python-colorama", "0.3.2-3.el7.noarch from epel"], ["fontconfig", 
"2.13.0-4.3.amzn2.x86_64 from amzn2-core"], ["microcode_ctl", 
"2:2.1-47.amzn2.0.6.x86_64 from amzn2-core"], ["pystache", 
"0.5.3-2.el7.noarch from epel"], ["python2-jsonschema", "2.5.1-4.el7.noarch 
from epel"], ["sscg", "2.6.1-1.el7.x86_64 from epel"], ["git-core", 
"2.23.3-1.amzn2.0.1.x86_64 from amzn2-core"], ["python-pillow", 
"2.0.0-20.gitd1c6db8.amzn2.0.1.x86_64 from amzn2-core"], 
["gtk-update-icon-cache", "3.22.30-3.amzn2.x86_64 from amzn2-core"], 
["freetype", "2.8-14.amzn2.x86_64 from amzn2-core"], ["avahi-libs", 
"0.6.31-19.amzn2.0.1.x86_64 from amzn2-core"], ["gdk-pixbuf2", 
"2.36.12-3.amzn2.x86_64 from amzn2-core"], ["python2-jmespath", 
"0.9.4-1.el7.noarch from epel"], ["nagios-plugins-nrpe", 
"4.0.2-1.el7.x86_64 from epel"], ["telnet", "1:0.17-65.amzn2.x86_64 from 
amzn2-core"], ["libglvnd-egl", "1:1.0.1-0.1.git5baa1e5.amzn2.0.1.x86_64 
from amzn2-core"], ["libidn2", "2.3.0-1.el7.x86_64 from epel"], ["libdrm", 
"2.4.97-2.amzn2.x86_64 from amzn2-core"], ["mesa-libEGL", 
"18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["python2-futures", 
"3.0.5-1.el7.noarch from epel"], ["libwayland-client", 
"1.17.0-1.amzn2.x86_64 from amzn2-core"], ["mesa-libGL", 
"18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], ["libX11-common", 
"1.6.7-2.amzn2.noarch from amzn2-core"], ["pango", "1.42.4-4.amzn2.x86_64 
from amzn2-core"], ["kernel-tools", "4.14.177-139.253.amzn2.x86_64 from 
amzn2-core"], ["kernel-headers", "4.14.177-139.253.amzn2.x86_64 from 
amzn2-core"], ["pgdg-redhat-repo", "42.0-6.noarch from pgdg94"], 
["fribidi", "1.0.2-1.amzn2.1.x86_64 from amzn2-core"], ["nrpe", 
"4.0.2-1.el7.x86_64 from epel"], ["python-jinja2", "2.8-7.rhel7.noarch from 
pgdg94"], ["mesa-libglapi", "18.3.4-5.amzn2.0.1.x86_64 from amzn2-core"], 
["python-repoze-lru", "0.4-3.el7.noarch from epel"], ["nagios-plugins", 
"2.3.3-2.el7.x86_64 from epel"], ["git-core-doc", 
"2.23.3-1.amzn2.0.1.noarch from amzn2-core"], ["python-lockfile", 
"1:0.9.1-4.el7.noarch from epel"], ["yum", "3.4.3-158.amzn2.0.4.noarch from 
amzn2-core"], ["python-daemon", "1.6-4.el7.noarch from epel"], ["glib2", 
"2.56.1-5.amzn2.0.1.x86_64 from amzn2-core"], ["php55-php-pear", 
"1:1.10.12-1.el7.remi.noarch from remi-safe"], ["awscli", 
"1.16.300-1.amzn2.0.2.noarch from amzn2-core"], ["libmetalink", 
"0.1.3-1.el7.x86_64 from epel"]]}, "msg": "Error: Package: 
pgdg-redhat-repo-42.0-6.noarch (pgdg94)\n   Requires: 
/etc/redhat-release\n", "obsoletes": {"pgdg-centos94": {"dist": "noarch", 
"repo": "installed", "version": "9.4-3"}}, "rc": 1, "results": ["Loaded 
plugins: langpacks, update-motd\nResolving Dependencies\n--> Running 
transaction check\n---> Package avahi-libs.x86_64 0:0.6.31-19.amzn2 will be 
updated\n---> Package avahi-libs.x86_64 0:0.6.31-19.amzn2.0.1 will be an 
update\n---> Package awscli.noarch 0:1.16.300-1.amzn2.0.1 will be 
updated\n---> Package awscli.noarch 0:1.16.300-1.amzn2.0.2 will be an 
update\n---> Package cairo.x86_64 0:1.14.8-2.amzn2.0.2 will be 
updated\n---> Package cairo.x86_64 0:1.15.12-4.amzn2 will be an 
update\n---> Package fontconfig.x86_64 0:2.10.95-11.amzn2.0.2 will be 
updated\n---> Package fontconfig.x86_64 0:2.13.0-4.3.amzn2 will be an 
update\n--> Processing Dependency: dejavu-sans-fonts for package: 
fontconfig-2.13.0-4.3.amzn2.x86_64\n---> Package freetype.x86_64 
0:2.4.11-15.amzn2.0.2 will be updated\n---> Package freetype.x86_64 
0:2.8-14.amzn2 will be an 

[ansible-project] Re: How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread David Foley


Using the Example Curl -X you can use the Ansible URI Module curl -X POST 
http://developer:developer@localhost:8080/job/test/buildWithParameter 
--data-urlencode json='{"parameter": [{"name":"paramA", "value":"123"}]}'---
  - name: Jenkins Remote Build 
hosts: localhost
connection: local
tasks:
- name: Adding Virtual Machine to Blackout
  uri:
url: 
http://developer:developer@localhost:8080/job/test/buildWithParameter
method: POST
body_format: JSON
body:
"{\"parameter\": [{\"name\":\"Test\"}, 
{\"vaule\":\"123\"}]}status_code: 200


-- 
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/493bd37e-c52c-49e2-8280-9353b423023d%40googlegroups.com.


Re: [ansible-project] Create user with ssh key, error deploying key

2020-05-07 Thread Joe G

>
> I appreciate the suggestion though I don't believe that is the solution to 
>> my problem, right? I suppose I should have posted the actual playbook I'm 
>> working with. The one previously provided was just a test one.  
>
>
Here's the task yml file within the role 

- include_vars: users.yml
- name: Create Users On VMs
  user: name="{{ item.username }}"
  with_items: "{{ users }}"
  #shell: /bin/bash
  #groups:

- name: Add .ssh Keys and Directories
  authorized_key: >
user="{{item.username}}"
key="{{ lookup('file', './files/{{ item.username}}_id_rsa.pub')}}"
  with_items: "{{ users }}"

 Error
failed: [test.preprod.io] (item={u'username': u'joe'}) => {
"changed": false, 
"item": {
"username": "joe"
}, 
"module_stderr": "OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2u  20 
Dec 2019\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying 
options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 
setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 
4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 
remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: 
mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: 
done pid = 22809\r\ndebug3: mux_client_request_session: session request 
sent\r\ndebug1: mux_client_request_session: master session id: 
2\r\nTraceback (most recent call last):\n  File \"\", line 113, in 
\n  File \"\", line 105, in _ansiballz_main\n  File 
\"\", line 48, in invoke_module\n  File 
\"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 678, in 
\n  File 
\"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 673, in 
main\n  File \"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", 
line 572, in enforce_state\n  File 
\"/tmp/ansible_authorized_key_payload_GKpQf3/__main__.py\", line 439, in 
parsekey\nIndexError: list index out of range\ndebug3: 
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
exit status from master 1\r\n", 
"module_stdout": "", 
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
"rc": 1
}



-- 
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/d41dc096-c6e8-4fa5-b31b-b495d3e8a4b1%40googlegroups.com.


[ansible-project] Re: How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread Mimo
it is not clear how to make the params as input there, it is easy to make 
it through Jenkins pipelines, but I am using Ansible, so I am expecting to 
have a Jenkins module that will build a job in Jenkins (or in my case 
handle the params to already existing job in Jenkins

On Thursday, May 7, 2020 at 10:02:20 PM UTC+2, David Foley wrote:
>
> Hi,
>
> In order to push jobs from Ansible or even Python to Jenkins you need to 
> make sure Remote Trigger is enable and an API Token has been created for 
> your Jenkins User. You can Then just use a Post request using the Ansible 
> URI module 
>

-- 
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/928edc51-e64c-4961-9a67-5acb8b31497a%40googlegroups.com.


[ansible-project] Re: How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread Mimo
so I aam expecting to have a jenkins module that will have a params that 
will be passed to the already existing Jenkins Job and it will triggerit

On Thursday, May 7, 2020 at 10:02:20 PM UTC+2, David Foley wrote:
>
> Hi,
>
> In order to push jobs from Ansible or even Python to Jenkins you need to 
> make sure Remote Trigger is enable and an API Token has been created for 
> your Jenkins User. You can Then just use a Post request using the Ansible 
> URI module 
>

-- 
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/b6f57e11-bcb2-4c2c-ab66-3b12b98b94a7%40googlegroups.com.


[ansible-project] Re: How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread Mimo
it is not clear how to make the params as input there, it is easy to make 
it through Jenkins pipelines, but I am using Ansible, so I am expecting to 
have a Jenkins module that will build a job in Jenkins (or in my case 
handle the params to already existing job in Jenkins)

On Thursday, May 7, 2020 at 10:02:20 PM UTC+2, David Foley wrote:
>
> Hi,
>
> In order to push jobs from Ansible or even Python to Jenkins you need to 
> make sure Remote Trigger is enable and an API Token has been created for 
> your Jenkins User. You can Then just use a Post request using the Ansible 
> URI module 
>

-- 
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/a7a4c599-10d1-4fe5-a8af-8eecf0eb64a4%40googlegroups.com.


Re: [ansible-project] How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread Mimo
can you explain in more details please? it is not clear to me

On Thu, May 7, 2020 at 10:02 PM David Foley  wrote:

> Hi,
>
> In order to push jobs from Ansible or even Python to Jenkins you need to
> make sure Remote Trigger is enable and an API Token has been created for
> your Jenkins User. You can Then just use a Post request using the Ansible
> URI module
>
> --
> 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/81063e55-65f0-487d-9953-03a2cd19b00c%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/CAJGmwppiKowc1aOfo9-mZZKE4idrDeb3W36kjkobh_1zK8gbig%40mail.gmail.com.


[ansible-project] Re: Windows service recovery on failure with ansible?

2020-05-07 Thread 'J Hawkesworth' via Ansible Project
I thought someone had added recovery actions to win_service module, but 
maybe that PR never got finished, or I am confused with dependent services.

I think you would have to use script module and some powershell to set 
recovery actions.  You could maybe use sc.exe too if you are in a hurry, 
although it would repeat the command every time you run the playbook.  
Maybe that doesn't matter though, it depends on what you need to get done.

Hope this helps,

Jon

On Thursday, May 7, 2020 at 8:42:45 PM UTC+1, vinod devops wrote:
>
> Hi Friends,
>
> How do I set windows service recovery on. failure, 
>
> suppose x service stopped due to failure, it needs to started 
> automatically by creating recovery condition with. ansible windows service?
>
>
> How do I do that ? 
>
> Thanks
> vinod
>

-- 
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/27d5d495-bb64-48f8-a125-d0a44588715f%40googlegroups.com.


[ansible-project] How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread David Foley
Hi,

In order to push jobs from Ansible or even Python to Jenkins you need to make 
sure Remote Trigger is enable and an API Token has been created for your 
Jenkins User. You can Then just use a Post request using the Ansible URI module 

-- 
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/81063e55-65f0-487d-9953-03a2cd19b00c%40googlegroups.com.


[ansible-project] How to pass params from Ansible to Jenkins Job triggered by Ansible Playbook?

2020-05-07 Thread Mimo


Hello everyone,

I checked Ansible documentation, I did not find answers there or anywhere 
of how I can pass params to the Jenkins Job,so these params should be as an 
input params to this Jenkins Job and they will be used in that Job, So is 
there a way to make this happen?

Thank you already for your answers

-- 
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/4171a119-1fd4-4401-aa61-40615e32b550%40googlegroups.com.


Re: [ansible-project] Create user with ssh key, error deploying key

2020-05-07 Thread Michael Mullay
Joe,

If the path to the ssh key is in the current Role, you could just write is
as:

key="{{ lookup('file', 'files/joe_id_rsa.pub') }}"
state=present

If that doesn't work I would try putting the key in the same directory as
the playbook and just  do:

key="{{ lookup('file', './joe_id_rsa.pub') }}"
state=present

I believe the lookup will look for 'files' in the files directory off the
root of the playbook or role just like copy or template would. Or you could
use an absolute path to the key file.


On Thu, May 7, 2020 at 12:05 PM Joe G  wrote:

> Need help with the error I'm getting trying to create users with ssh
> keys.  It creates the user fine but when it comes time to deploy the ssh
> key it fails.  I've tried this using a couple different playbooks and both
> similarly error out. I believe this was the online guide I followed. I've
> looked at so many I can't recall:
>
> https://medium.com/@khandelwal12nidhi/setup-ssh-key-and-initial-user-using-ansible-playbook-61eabbb0dba4
>
> Playbook
> - hosts: test.preprod.io
>   gather_facts: no
>   remote_user: ansible
>   become: yes
>
>   tasks:
>   - name: Create Users
> user:
>   name: joe
>   shell: /bin/bash
>
>   - name: Add user to the sudoers
> copy:
>  dest: "/etc/sudoers.d/joe"
>  content: "joe  ALL=(ALL)  NOPASSWD: ALL"
>   - name: Deploy SSH Key
> authorized_key: user=joe
> key="{{ lookup('file',
> 'roles/manage-ssh-users/files/joe_id_rsa.pub') }}"
> state=present
>
>
>
> Error:
> fatal: [test.preprod.io]: FAILED! => {
> "changed": false,
> "module_stderr": "OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2u  20
> Dec 2019\r\ndebug1: Reading configuration data
> /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying
> options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3
> setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version
> 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0
> remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3:
> mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive:
> done pid = 18482\r\ndebug3: mux_client_request_session: session request
> sent\r\ndebug1: mux_client_request_session: master session id:
> 2\r\nTraceback (most recent call last):\n  File \"\", line 113, in
> \n  File \"\", line 105, in _ansiballz_main\n  File
> \"\", line 48, in invoke_module\n  File
> \"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", line 678, in
> \n  File
> \"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", line 673, in
> main\n  File \"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\",
> line 572, in enforce_state\n  File
> \"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", line 439, in
> parsekey\nIndexError: list index out of range\ndebug3:
> mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received
> exit status from master 1\r\n",
> "module_stdout": "",
> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
> "rc": 1
> }
>
> Version info:
> ansible@ansible:~$ ansible --version
> ansible 2.7.10.post0
>   config file = /home/ansible/ansible.cfg
>   configured module search path =
> [u'/home/ansible/.ansible/plugins/modules',
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location =
> /usr/local/lib/python2.7/dist-packages/ansible-2.7.10.post0-py2.7.egg/ansible
>   executable location = /usr/local/bin/ansible
>   python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0
> 20170516]
>
>
> Config:
> [defaults]
> inventory  = ./hosts
> log_path = /var/log/ansible.log
> retry_files_enabled = False
> [privilege_escalation]
> [paramiko_connection]
> [ssh_connection]
> ssh_arg = -o ServerAliveInterval=30 -o ControlMaster=auto -o
> ControlPersist=60s
> pipelining = True
> [accelerate]
> [selinux]
> [colors]
>
>
>
>
> --
> 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/a9755b39-a860-4440-9509-f91ddf246325%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/CAH4rTPv%3DxF-MRukYdhjqscrh6qe6O_V2dsgjaC932Dy%2BAPXH4w%40mail.gmail.com.


[ansible-project] Windows service recovery on failure with ansible?

2020-05-07 Thread vinod devops
Hi Friends,

How do I set windows service recovery on. failure, 

suppose x service stopped due to failure, it needs to started automatically 
by creating recovery condition with. ansible windows service?


How do I do that ? 

Thanks
vinod

-- 
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/77ced6c2-82ed-48ed-aa41-c72422292b26%40googlegroups.com.


[ansible-project] ansible error: msg: 'An unhandled exception occurred while templating' in regex_replace

2020-05-07 Thread Meir Yanovich
i have this task which should create random dir download file to the random 
dir 
but I keep getting an error on the regexp :





  
  ---
- name: check if exists
  hosts: localhost
  gather_facts: false
  tasks:
- debug:
msg: "### This is start 
###"

- name: Handle the error
  block:
- name: ansible create directory with mode 
setting example
  vars:
name_dir: "{{ 1000 | random | to_uuid  }}"
  file:
  path: "/home/ec2-user/backup/{{ name_dir 
}}/"
  state: directory

- name: Download from s3
  vars:
 obj_name: "{{ 
'http://www.foo.bbb/foo/.zip' | regex_replace('^(?:\/\/|[^\/]+)*\/', 
'') }}"
 file_name: "{{ 
'http://www.foo.bbb/foo/.zip' | regex_search('[^\/]+$', '') }}"
  local_action:
module: aws_s3
bucket: pack
object: "{{ obj_name }}"
dest: "/home/ec2-user/backup/{{ 
name_dir }}/{{ file_name }}"
mode: get
- debug:
msg: " 
{{ obj_name }}   {{ file_name }} ##  {{ 
name_dir }} #"
  rescue:
- debug:
msg: 'I caught an error, can do stuff 
here to fix it, :-)'






Here is the error:

   
 TASK [Download from s3] 
*
task path: /home/ec2-user/backup/test7.yml:18
Thursday 07 May 2020  16:11:59 + (0:00:00.297)   0:00:00.381 
**
fatal: [localhost]: FAILED! =>
  msg: 'An unhandled exception occurred while templating ''{{ 
''http://www.foo.bbb/foo/.zip'' | regex_search(''[^/]+$'', ) }}''. 
Error was a , original 
message: Unknown argument'




but the wired thing is that here it is working fine :

---
- name: check if exsist
  hosts: localhost
  gather_facts: false
  tasks:
- debug:
 var: "{{ '
obj_name: "{{ 'http://www.foo.bbb/foo/.zip' | regex_replace(
'^(?:\/\/|[^\/]+)*\/', '') }}"



-- 
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/1b65e2c0-fa8a-4a7b-ae07-c284f1b0d88f%40googlegroups.com.


[ansible-project] Create user with ssh key, error deploying key

2020-05-07 Thread Joe G
Need help with the error I'm getting trying to create users with ssh keys.  
It creates the user fine but when it comes time to deploy the ssh key it 
fails.  I've tried this using a couple different playbooks and both 
similarly error out. I believe this was the online guide I followed. I've 
looked at so many I can't recall:
https://medium.com/@khandelwal12nidhi/setup-ssh-key-and-initial-user-using-ansible-playbook-61eabbb0dba4

Playbook
- hosts: test.preprod.io
  gather_facts: no
  remote_user: ansible
  become: yes

  tasks:
  - name: Create Users
user:
  name: joe
  shell: /bin/bash

  - name: Add user to the sudoers
copy:
 dest: "/etc/sudoers.d/joe"
 content: "joe  ALL=(ALL)  NOPASSWD: ALL"
  - name: Deploy SSH Key
authorized_key: user=joe
key="{{ lookup('file', 
'roles/manage-ssh-users/files/joe_id_rsa.pub') }}"
state=present



Error:
fatal: [test.preprod.io]: FAILED! => {
"changed": false, 
"module_stderr": "OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2u  20 
Dec 2019\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying 
options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 
setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 
4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 
remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: 
mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: 
done pid = 18482\r\ndebug3: mux_client_request_session: session request 
sent\r\ndebug1: mux_client_request_session: master session id: 
2\r\nTraceback (most recent call last):\n  File \"\", line 113, in 
\n  File \"\", line 105, in _ansiballz_main\n  File 
\"\", line 48, in invoke_module\n  File 
\"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", line 678, in 
\n  File 
\"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", line 673, in 
main\n  File \"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", 
line 572, in enforce_state\n  File 
\"/tmp/ansible_authorized_key_payload_bQp3_I/__main__.py\", line 439, in 
parsekey\nIndexError: list index out of range\ndebug3: 
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
exit status from master 1\r\n", 
"module_stdout": "", 
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
"rc": 1
}

Version info:
ansible@ansible:~$ ansible --version
ansible 2.7.10.post0
  config file = /home/ansible/ansible.cfg
  configured module search path = 
[u'/home/ansible/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = 
/usr/local/lib/python2.7/dist-packages/ansible-2.7.10.post0-py2.7.egg/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 
20170516]


Config:
[defaults]
inventory  = ./hosts
log_path = /var/log/ansible.log
retry_files_enabled = False
[privilege_escalation]
[paramiko_connection]
[ssh_connection]
ssh_arg = -o ServerAliveInterval=30 -o ControlMaster=auto -o 
ControlPersist=60s
pipelining = True
[accelerate]
[selinux]
[colors]




-- 
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/a9755b39-a860-4440-9509-f91ddf246325%40googlegroups.com.


Re: [ansible-project] Ansible lininfile behavior

2020-05-07 Thread Kai Stian Olstad
On Thu, May 07, 2020 at 02:22:54PM -0400, Justin Nelson wrote:
> I just wanted to say thanks for your help in pointing out where I went
> wrong. Setting the play that was contending for a single file to serial: 1
> did the trick. When our ansible controller gets upgraded to 2.9 I'll use
> throttle to limit just that one task.
> 
> Everything is working as expected, and better than it was before.

You don't need run with serial: 1 if you use your loop below and add
run_once: yes.

That is what I do in cases like this because it's lot faster than serial: 1.


> > On Mon, May 04, 2020 at 02:02:13PM -0700, Justin Nelson wrote:
> > > - name: Update tmp file
> > >   lineinfile:
> > > path: "{{ playbook_dir }}/macs.yaml"
> > > regexp: "^\ \ test[.-]{{ test_string|lower }}:.*"
> > > line: "  test-{{test_string|lower}}: {{mac}}"
> > > create: yes
> > >   loop: "{{ ansible_play_hosts }}"
> > >   vars:
> > > test_string: "{{ hostvars[item]['test_string'] }}"
> > > mac: "{{ hostvars[item]['mac'] }}"

  - name: Update tmp file
lineinfile:
  path: "{{ playbook_dir }}/macs.yaml"
  regexp: "^\ \ test[.-]{{ test_string|lower }}:.*"
  line: "  test-{{test_string|lower}}: {{mac}}"
  create: yes
loop: "{{ ansible_play_hosts }}"
run_once: yes
vars:
  test_string: "{{ hostvars[item]['test_string'] }}"
  mac: "{{ hostvars[item]['mac'] }}"

-- 
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/20200507184548.4mncbnlib3gktbfg%40olstad.com.


Re: [ansible-project] Ansible lininfile behavior

2020-05-07 Thread Justin Nelson
Kai,

I just wanted to say thanks for your help in pointing out where I went
wrong. Setting the play that was contending for a single file to serial: 1
did the trick. When our ansible controller gets upgraded to 2.9 I'll use
throttle to limit just that one task.

Everything is working as expected, and better than it was before.

Thanks again.

On Mon, May 4, 2020 at 5:18 PM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On Mon, May 04, 2020 at 02:02:13PM -0700, Justin Nelson wrote:
> > The two hosts I have to test with are running 2.7.4 and 2.8.2. I don't
> have
> > a 2.9.x host available to test the throttle command but it makes sense.
> >
> > However, when I updated the playbook to the following:
> >
> > ---
> > - name: Test Playbook
> >   hosts:
> > - test_group
> >   gather_facts: no
> >   connection: local
> >
> >   vars:
> > user_home: "{{ lookup('env', 'HOME') }}"
> > config_file: "{{ inventory_hostname }}.conf"
> >
> >   tasks:
> > - name: Load device vars from config
> >   include_vars: "{{ user_home }}/{{ inventory_hostname }}.conf"
> >
> > - name: Update tmp file
> >   lineinfile:
> > path: "{{ playbook_dir }}/macs.yaml"
> > regexp: "^\ \ test[.-]{{ test_string|lower }}:.*"
> > line: "  test-{{test_string|lower}}: {{mac}}"
> > create: yes
> >   loop: "{{ ansible_play_hosts }}"
> >   vars:
> > test_string: "{{ hostvars[item]['test_string'] }}"
> > mac: "{{ hostvars[item]['mac'] }}"
> >
> > It ran as follows:
> >
> > PLAY [Test Playbook]
> >
> 
> >
> > TASK [Load device vars from config]
> >
> *
> > ok: [host1]
> > ok: [host2]
> >
> > TASK [Update tmp file]
> >
> **
> > changed: [host2] => (item=host1)
> > changed: [host1] => (item=host1)
> > changed: [host1] => (item=host2)
> > ok: [host2] => (item=host2)
>
> Here also you have two task writing to the same file at the same time.
> So here you need to add "run_once: yes" to the lineinfile task.
>
> --
> 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/20200504211803.rnrw6wb4rkawvmyo%40olstad.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/CAH_brx3c%2B4EKnqbvfM651VZnQVyeHxw-RwQEuLV5xOcNj__EKg%40mail.gmail.com.


[ansible-project] Re: include_vars - variable is not Serializable

2020-05-07 Thread Robert Wagner
Never mind - I had a typo that was leading to a not-helpful error message.

Thanks,

Rob


On Thursday, May 7, 2020 at 10:34:53 AM UTC-6, Robert Wagner wrote:
>
> Hi all. Wondering if somebody can point me in the right direction - Google 
> has led me on bit of a wild goose chase.
>
> I'm using ansible 2.9.6 on CentOS 7.7. 
>
> I have some vaulted vars that if I put in vars/main.yml work fine. If I 
> move the same vars to another file and include it (include_vars: 
> myfile.yml) , the play that uses them bombs.
>
> [WARNING]: Failure using method (v2_runner_on_ok) in callback plugin 
> ( 0x7ff965ec6a10>): u
> Errror "'myvar' is not JSON serializable".
>
> I'm reading it closer now that I've pasted it here that it does mention 
> foreman's CallbackModule in the error, but not sure if the issue is 
> introduced by Foreman running the playbook.
>
> Any advice would be appreciated,
>
> Rob
>

-- 
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/8bc1b8cc-7480-42ae-8b72-f10303af0131%40googlegroups.com.


[ansible-project] include_vars - variable is not Serializable

2020-05-07 Thread Robert Wagner
Hi all. Wondering if somebody can point me in the right direction - Google 
has led me on bit of a wild goose chase.

I'm using ansible 2.9.6 on CentOS 7.7. 

I have some vaulted vars that if I put in vars/main.yml work fine. If I 
move the same vars to another file and include it (include_vars: 
myfile.yml) , the play that uses them bombs.

[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin 
(): u
Errror "'myvar' is not JSON serializable".

I'm reading it closer now that I've pasted it here that it does mention 
foreman's CallbackModule in the error, but not sure if the issue is 
introduced by Foreman running the playbook.

Any advice would be appreciated,

Rob

-- 
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/bb5cc1ad-94eb-456a-bde1-54ffa2fd12bc%40googlegroups.com.


Re: [ansible-project] rpm--import issues

2020-05-07 Thread Dick Visser
Hi

No problem.
So the 'ansible way' is to use native modules wherever possible. The
shell/command task should be used only if there is no reasonable way
to achieve things using native modules.

In your case the ansible way could look something like this:

  tasks:
- name: Find RPM GPG keys
  find:
paths: /etc/pki/rpm-gpg
  register: gpg_found

- name: Ensure found keys are trusted
  rpm_key:
key: "{{ item.path }}"
state: present
  loop: "{{ gpg_found.files }}"


You will find that once run, subsequent runs will not actually do
anything anymore as the desired state will have been reached after the
first run: idempotence.

You can optionally tune these tasks, for instance to fit the pattern
of the key names, etc.






On Thu, 7 May 2020 at 13:43, Quad Zero  wrote:
>
> Hi Dick,
>
> Yes, so I may have replied to your comment above in my reply back to Michael.
>
> I guess my knowledge on Ansible is still very new, so currently just getting 
> things done, until I get to grips with better understanding.
>
> Could anyone please recommend any good books that covers most of the modules 
> in depth? Just trying to learn and last night was quite frustrating for me.
>
> Thank you once again.
>
> On Thursday, May 7, 2020 at 12:50:17 AM UTC-4, Dick Visser wrote:
>>
>> Indeed.
>>  I've noticed quite a few people are frantically trying to shoehorn shell 
>> commands into ansible. This works yes but lacks all the goodies that ansible 
>> brings such as idempotency etc.
>> The questions then tend to narrow down to why the output of a dozen twelve 
>> cat/grep/sed/awk pipes doesn't do what they want.
>>
>> In this case it's not clear why you'd want to blindly add all rpm keys. This 
>> once again looks like a sledgehammer and should instead be done by iterating 
>> over the keys you actually want, with rpm_key.
>>
>>
>> On Thu, 7 May 2020 at 01:16, Michael Mullay  wrote:
>>>
>>> Quad Zero,
>>> You didn't even indicate if you tried using the module JYL took the time to 
>>> point out to you. There are examples there and everything. If you want 
>>> pre-written Ansible code without doing any research or leg work you should 
>>> look on galaxy.ansible.com.
>>>
>>> And that is really weak criticizing someone that took more time to try to 
>>> solve your problem than you did. People are likely going to stop responding 
>>> to you after that comment.
>>>
>>>
>>> On Wed, May 6, 2020 at 4:01 PM Quad Zero  wrote:

 Thanks for your reply but really is not helpful bud.

 This is like if i asked how i can get to a destination, you are telling me 
 to go to a train or bus station.


 On Wednesday, May 6, 2020 at 7:32:08 AM UTC-4, Jean-Yves LENHOF wrote:
>
> Hi,
>
> There's a module to import key, please use it !
>
> https://docs.ansible.com/ansible/latest/modules/rpm_key_module.html
>
> Regards,
>
> JYL
>
> Le 06/05/2020 à 12:17, Quad Zero a écrit :
>
> Hi all,
>
> Thank you for your help in my last post. I have come quite a way (small 
> compared to many of you) but nevertheless making good progress each day.
>
> I hit roadblocks quite a bit and thankfully google has helped me quite a 
> bit. I have come across this problem now which I hope some of you can 
> explain and then help me with finding a solution. This is my code so far:
>
> ---
> - hosts: all
>   serial: 3
>   become: yes
>   tasks:
> - name: ping all the machines
>   ping:
>
> - name: Import all GPG keys for repo
>   command: "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*"
>
>
> When I am trying to run the rpm --import as a command, I get this error 
> on my 3 test hosts:
> 1. What does it mean, why is this producing an error? I can enter this 
> directly as a command in shell and it works just fine, so where is 
> Ansible having issues?
> 2. How can I fix this and find a solution so that all my keys from the 
> pki directory is imported as I have a mixture of RHEL and CentOS systems?
>
> TASK [Import all GPG keys for repo] 
> *
> [WARNING]: Consider using the yum, dnf or zypper module rather than 
> running 'rpm'.  If you need to use command because yum, dnf or
> zypper is insufficient you can add 'warn: false' to this command task or 
> set 'command_warnings=False' in ansible.cfg to get rid of this
> message.
> fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["rpm", 
> "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.029904", 
> "end": "2020-05-06 05:08:49.909745", "msg": "non-zero return code", "rc": 
> 1, "start": "2020-05-06 05:08:49.879841", "stderr": "error: 
> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 

[ansible-project] Include Vars, with_items , returned data with .results values

2020-05-07 Thread Adam McGill
I am using a include_vars file to pipe the variable to a libary/ps1/py file 
which will return results / verification.  Is there a way to not include 
the item data /ansible loop information in the .results data.  As I figured 
the .results data should only include the data I pipe back from the 
libary/ps1/py file results.  So with this example below if i sent over the 
installmedia_source/values , set the attrib in the PS1 file and returned it 
and displayed .results it still includes the .item info.  Unless anyone can 
suggest a better way to pass a include_vars values over to the ps1 
file/task.


[image: case-ansible forums.png]

-- 
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/345a68f1-5663-4ae8-b408-f4df907b6a94%40googlegroups.com.


Re: [ansible-project] unable to ssh

2020-05-07 Thread Dick Visser
Ansible is an automation tool that uses SSH as its transport.
Before automating things, make sure you can manually connect to the
device using SSH:

https://docs.ansible.com/ansible/latest/user_guide/connection_details.html

Fixing SSH problems is not in scope for this list, but in this case
the error is very clear and obvious: no matching key exchange method
found.
Google that and the first hit will explain what your problem is (and
how to fix it).

Also, you are running ansible as user 'root' - this is dangerous and
unnecessary.


Dick


On Thu, 7 May 2020 at 16:18, Hitesh Kumar  wrote:
>
> Hi All
>
> I am facing ssh connection issues with my network switch, need help to 
> establish ssh connection
>
> root@VPC260:/etc/ansible# ssh 10.25.200.1
> Unable to negotiate with 10.25.200.1 port 22: no matching key exchange method 
> found. Their offer: 
> diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
> root@VPC260:/etc/ansible# ansible -m ping 10.25.200.1
> 10.25.200.1 | UNREACHABLE! => {
> "changed": false,
> "msg": "Failed to connect to the host via ssh: Unable to negotiate with 
> 10.25.200.1 port 22: no matching key exchange method found. Their offer: 
> diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1",
> "unreachable": true
> }
>
> Regards
> Hitesh
>
> --
> 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/CANQHRf1EdNK0-7KjnX9%2Bn257%2B%2BeTJpp4%3DbhAjY4vEzENt_oONg%40mail.gmail.com.



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


[ansible-project] Include Vars / With_items / returned data options

2020-05-07 Thread Adam McGill

I am using a include_vars file to pipe the variable to a libary/ps1/py file 
which will return results / verification.  Is there a way to not include 
the item data /ansible loop information in the .results data.  As I figured 
the .results data should only include the data I pipe back from the 
libary/ps1/py file results.  So with this example below if i sent over the 
installmedia_source/values , set the attrib in the PS1 file and returned it 
and displayed .results it still includes the .item info.  Unless anyone can 
suggest a better way to pass a include_vars values over to the ps1 
file/task.

[image: case-ansible forums.png]



-- 
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/d195f425-ebb8-4b13-a1f5-f37c102c58fc%40googlegroups.com.


[ansible-project] aireos_config with prompts

2020-05-07 Thread Scott Fella
Hello everyone,

Wanted to see if someone has a fix for what I'm trying to do.  First off, 
the aireos_command allows for "prompt" and "answer", but the aireos_config 
does not.  I have tried using the following:

""/r/ny/r/n 
""//r//ny//r//n 
""//ry//r


Here is the output from the controller cli:
(ciscowlc5508) >config ap group-name default-group new.1.CAP01

Changing the AP's group name will cause the AP to reboot.
Are you sure you want to continue? (y/n) 



The play completes, but nothing has changed.

  tasks:
  - name: configure ap settings
aireos_config:
  lines:
- "ap group-name {{item.apGroup}} {{item.newApName}}//ry//r"

PLAY [deploy_configure_ap] 
***

TASK [configure ap settings] 
*
changed: [rusredrwac5501] => (item={u'apGroup': u'default-group', 
u'oldApName': u'test.1.CAP01', u'newApName': u'new.1.CAP01', 
u'sysLocation': u'site-1'})
[DEPRECATION WARNING]: Distribution Ubuntu 16.04 on host ciscowlc5508 
should use /usr/bin/python3, but is using /usr/bin/python for backward 
compatibility with prior Ansible releases. A future 
Ansible release will default to using the discovered platform python for 
this host. See 
https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.html
 
for more information. This 
feature will be removed in version 2.12. Deprecation warnings can be 
disabled by setting deprecation_warnings=False in ansible.cfg.

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

Thanks,
-Scott

-- 
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/4c945cc5-21db-4bc7-bd6d-ae936040b9fd%40googlegroups.com.


Re: [ansible-project] Adding task output to a file in a loop

2020-05-07 Thread Vladimir Botka
On Wed, 6 May 2020 12:41:54 -0700 (PDT)
harry devine  wrote:

> for uid in {1000..6500}
>   user = ipa user-find --uid=$uid --raw |grep uid: | awk '{print $2}'
>   echo "user,uid" >> uid.csv
> do

This is the Ansible equivalent, I think.

The module "getent" creates the dictionary "getent_passwd". Next "set_fact"
creates the list of dictionaries with attributes "user" and "uid" only. Next
"set_fact" selects required "uid" and module "template"  writes the file.

  - getent:
  database: passwd
  - set_fact:
  my_list: "{{ getent_passwd|
   dict2items|
   json_query('[].{user: key, uid: to_number(value[1])}')
   }}"
  - set_fact:
  my_list: "{{ my_list|
   json_query('[?uid >= `1000`]')|
   json_query('[?uid <= `65000`]')|
   sort(attribute='uid')|
   list }}"
  - template:
  src: uid.csv.j2
  dest: uid.csv

This is the template

  shell> cat uid.csv.j2
  {% for item in my_list %}
  {{ item.user }},{{ item.uid }}
  {% endfor %}

Notes

  * The function "to_number" is needed to store uid as numbers
https://jmespath.readthedocs.io/en/latest/proposals/functions.html#to-number

  * The file "uid.csv" will be created on the remote host.

  * To create the file on the controller use "delegate_to" and mark the file
by the remote hostname. For example

  - template:
  src: uid.csv.j2
  dest: "{{ inventory_hostname }}-uid.csv"
delegate_to: localhost

,or use module "fetch". See parameter "flat"

https://docs.ansible.com/ansible/latest/modules/fetch_module.html#parameter-flat

HTH,

-vlado

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


pgpJb_5i1d32_.pgp
Description: OpenPGP digital signature


[ansible-project] unable to ssh

2020-05-07 Thread Hitesh Kumar
Hi All

I am facing ssh connection issues with my network switch, need help to
establish ssh connection

root@VPC260:/etc/ansible# ssh 10.25.200.1
Unable to negotiate with 10.25.200.1 port 22: no matching key exchange
method found. Their offer:
diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
root@VPC260:/etc/ansible# ansible -m ping 10.25.200.1
10.25.200.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Unable to negotiate with
10.25.200.1 port 22: no matching key exchange method found. Their offer:
diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1",
"unreachable": true
}

Regards
Hitesh

-- 
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/CANQHRf1EdNK0-7KjnX9%2Bn257%2B%2BeTJpp4%3DbhAjY4vEzENt_oONg%40mail.gmail.com.


[ansible-project] Re: fortigate / fortinet

2020-05-07 Thread Andrew Meyer
Here is what I am getting:

ansible -m ping 10.150.1.1 --user=ansible
[WARNING]: sftp transfer mechanism failed on [10.150.1.1]. Use 
ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on [10.150.1.1]. Use 
ANSIBLE_DEBUG=1 to see detailed information
10.150.1.1 | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 10.150.1.1 closed.\r\n",
"module_stdout": "fw01 # Unknown action 0\r\n\r\nfw01 # ",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}

ansible -m ping fw01.loc.example.com --user=ansible
[WARNING]: sftp transfer mechanism failed on [fw01.loc.example.com]. Use 
ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on [fw01.loc.example.com]. Use 
ANSIBLE_DEBUG=1 to see detailed information
fw01.loc.example.com | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to fw01.loc.example.com closed.\r\n",
"module_stdout": "fw01 # Unknown action 0\r\n\r\nfw01 # ",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}

On Wednesday, May 6, 2020 at 2:49:51 PM UTC-5, Andrew Meyer wrote:
>
> Has anyone gotten a fortinet/fortigate playbook to work?  I have a 
> Fortigate 100D running 6.2.2 and I can't get it to pass an ansible ping.
>

-- 
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/7723cddc-9573-4d98-a76c-eb81d3761b9d%40googlegroups.com.


[ansible-project] Cisco interface state change

2020-05-07 Thread sayantan laha
Dear all,

I am newbie in ansible.
My requirment is like when i see an interface in suspended mode want to bring 
back to UP for all cisco device.
Please help how do i apply conditional way.

-- 
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/4f785c06-5fce-438e-acb9-a9ddb08748ab%40googlegroups.com.


Re: [ansible-project] rpm--import issues

2020-05-07 Thread Quad Zero
Apologies to you also Racke. Thank you for pointing this out. 

On Thursday, May 7, 2020 at 2:02:31 AM UTC-4, Stefan Hornburg (Racke) wrote:
>
> On 5/7/20 1:01 AM, Quad Zero wrote: 
> > Thanks for your reply but really is not helpful bud. 
> > 
> > This is like if i asked how i can get to a destination, you are telling 
> me to go to a train or bus station. 
> > 
>
> That was a bad move from you if you ask me. 
>
> Regards 
>   Racke 
> > 
> > On Wednesday, May 6, 2020 at 7:32:08 AM UTC-4, Jean-Yves LENHOF wrote: 
> > 
> > Hi, 
> > 
> > There's a module to import key, please use it ! 
> > 
> > https://docs.ansible.com/ansible/latest/modules/rpm_key_module.html 
> >  
>
> > 
> > Regards, 
> > 
> > JYL 
> > 
> > Le 06/05/2020 à 12:17, Quad Zero a écrit : 
> >> Hi all, 
> >> 
> >> Thank you for your help in my last post. I have come quite a way 
> (small compared to many of you) but nevertheless 
> >> making good progress each day. 
> >> 
> >> I hit roadblocks quite a bit and thankfully google has helped me 
> quite a bit. I have come across this problem now 
> >> which I hope some of you can explain and then help me with finding 
> a solution. This is my code so far: 
> >> 
> >> --- 
> >> - hosts: all 
> >>   serial: 3 
> >>   become: yes 
> >>   tasks: 
> >> - name: ping all the machines 
> >>   ping: 
> >> 
> >> - name: Import all GPG keys for repo 
> >>   command: "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*" 
> >> 
> >> 
> >> When I am trying to run the rpm --import as a command, I get this 
> error on my 3 test hosts: 
> >> 1. What does it mean, why is this producing an error? I can enter 
> this directly as a command in shell and it works 
> >> just fine, so where is Ansible having issues? 
> >> 2. How can I fix this and find a solution so that all my keys from 
> the pki directory is imported as I have a 
> >> mixture of RHEL and CentOS systems? 
> >> 
> >> TASK [Import all GPG keys for repo] 
> >> 
> *
>  
>
> >> [WARNING]: Consider using the yum, dnf or zypper module rather than 
> running 'rpm'.  If you need to use command 
> >> because yum, dnf or 
> >> zypper is insufficient you can add 'warn: false' to this command 
> task or set 'command_warnings=False' in 
> >> ansible.cfg to get rid of this 
> >> message. 
> >> fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["rpm", 
> "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], 
> >> "delta": "0:00:00.029904", "end": "2020-05-06 05:08:49.909745", 
> "msg": "non-zero return code", "rc": 1, "start": 
> >> "2020-05-06 05:08:49.879841", "stderr": "error: 
> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", 
> >> "stderr_lines": ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import 
> read failed(2)."], "stdout": "", "stdout_lines": []} 
> >> fatal: [testb_centos78]: FAILED! => {"changed": true, "cmd": 
> ["rpm", "--import", 
> >> "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027775", 
> "end": "2020-05-06 05:08:50.031696", "msg": 
> >> "non-zero return code", "rc": 1, "start": "2020-05-06 
> 05:08:50.003921", "stderr": "error: 
> >> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", 
> "stderr_lines": ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: 
> >> import read failed(2)."], "stdout": "", "stdout_lines": []} 
> >> fatal: [testa_centos78]: FAILED! => {"changed": true, "cmd": 
> ["rpm", "--import", 
> >> "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027843", 
> "end": "2020-05-06 05:08:50.035566", "msg": 
> >> "non-zero return code", "rc": 1, "start": "2020-05-06 
> 05:08:50.007723", "stderr": "error: 
> >> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", 
> "stderr_lines": ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: 
> >> import read failed(2)."], "stdout": "", "stdout_lines": []} 
> >> 
> >> Thanks in advance everyone. 
> >> -- 
> >> 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/cf399d8a-bba9-49b8-afe9-6d07516eb99f%40googlegroups.com
>  
> >> <
> https://groups.google.com/d/msgid/ansible-project/cf399d8a-bba9-49b8-afe9-6d07516eb99f%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > 
> > -- 
> > 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   

Re: [ansible-project] rpm--import issues

2020-05-07 Thread Quad Zero
Hi Dick,

Yes, so I may have replied to your comment above in my reply back to 
Michael. 

I guess my knowledge on Ansible is still very new, so currently just 
getting things done, until I get to grips with better understanding. 

Could anyone please recommend any good books that covers most of the 
modules in depth? Just trying to learn and last night was quite frustrating 
for me. 

Thank you once again. 

On Thursday, May 7, 2020 at 12:50:17 AM UTC-4, Dick Visser wrote:
>
> Indeed.
>  I've noticed quite a few people are frantically trying to shoehorn shell 
> commands into ansible. This works yes but lacks all the goodies that 
> ansible brings such as idempotency etc.
> The questions then tend to narrow down to why the output of a dozen twelve 
> cat/grep/sed/awk pipes doesn't do what they want.
>
> In this case it's not clear why you'd want to blindly add all rpm keys. 
> This once again looks like a sledgehammer and should instead be done by 
> iterating over the keys you actually want, with rpm_key.
>
>
> On Thu, 7 May 2020 at 01:16, Michael Mullay  > wrote:
>
>> Quad Zero,
>> You didn't even indicate if you tried using the module JYL took the time 
>> to point out to you. There are examples there and everything. If you want 
>> pre-written Ansible code without doing any research or leg work you should 
>> look on galaxy.ansible.com. 
>>
>> And that is really weak criticizing someone that took more time to try to 
>> solve your problem than you did. People are likely going to stop responding 
>> to you after that comment.
>>  
>>
>> On Wed, May 6, 2020 at 4:01 PM Quad Zero > 
>> wrote:
>>
>>> Thanks for your reply but really is not helpful bud.
>>>
>>> This is like if i asked how i can get to a destination, you are telling 
>>> me to go to a train or bus station. 
>>>
>>>
>>> On Wednesday, May 6, 2020 at 7:32:08 AM UTC-4, Jean-Yves LENHOF wrote:

 Hi,

 There's a module to import key, please use it !

 https://docs.ansible.com/ansible/latest/modules/rpm_key_module.html

 Regards,

 JYL
 Le 06/05/2020 à 12:17, Quad Zero a écrit :

 Hi all,

 Thank you for your help in my last post. I have come quite a way (small 
 compared to many of you) but nevertheless making good progress each day. 

 I hit roadblocks quite a bit and thankfully google has helped me quite 
 a bit. I have come across this problem now which I hope some of you can 
 explain and then help me with finding a solution. This is my code so far:

 ---
 - hosts: all
   serial: 3
   become: yes
   tasks:
 - name: ping all the machines
   ping:

 - name: Import all GPG keys for repo
   command: "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*"


 When I am trying to run the rpm --import as a command, I get this error 
 on my 3 test hosts:
 1. What does it mean, why is this producing an error? I can enter this 
 directly as a command in shell and it works just fine, so where is Ansible 
 having issues?
 2. How can I fix this and find a solution so that all my keys from the 
 pki directory is imported as I have a mixture of RHEL and CentOS systems?

 TASK [Import all GPG keys for repo] 
 *
 [WARNING]: Consider using the yum, dnf or zypper module rather than 
 running 'rpm'.  If you need to use command because yum, dnf or
 zypper is insufficient you can add 'warn: false' to this command task 
 or set 'command_warnings=False' in ansible.cfg to get rid of this
 message.
 fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["rpm", 
 "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.029904", 
 "end": "2020-05-06 05:08:49.909745", "msg": "non-zero return code", "rc": 
 1, "start": "2020-05-06 05:08:49.879841", "stderr": "error: 
 /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
 ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2)."], 
 "stdout": "", "stdout_lines": []}
 fatal: [testb_centos78]: FAILED! => {"changed": true, "cmd": ["rpm", 
 "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027775", 
 "end": "2020-05-06 05:08:50.031696", "msg": "non-zero return code", "rc": 
 1, "start": "2020-05-06 05:08:50.003921", "stderr": "error: 
 /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
 ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2)."], 
 "stdout": "", "stdout_lines": []}
 fatal: [testa_centos78]: FAILED! => {"changed": true, "cmd": ["rpm", 
 "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027843", 
 "end": "2020-05-06 05:08:50.035566", "msg": "non-zero return code", "rc": 
 1, "start": "2020-05-06 05:08:50.007723", "stderr": "error: 
 

Re: [ansible-project] rpm--import issues

2020-05-07 Thread Quad Zero
Hi Michael,

So I did search all the modules. My question was how to import all the keys 
from the /etc/pki... all i could find was individual loads, it was so that 
I run multiple CentOS and RedHat servers and some have different repos 
enabled, so bulk import would be a better solution I thought?

Sure, my bad, though I just asked myself how I would go about if someone 
asked me the same question. I would only reply directly to their question 
but that is just me. Anyways, don't want to stir anything further so 
apologies to all esp to JYL for my rude comment. 

Thank you to those that helped me and to everyone that replied to this 
thread :) 

On Wednesday, May 6, 2020 at 7:16:14 PM UTC-4, Michael M wrote:
>
> Quad Zero,
> You didn't even indicate if you tried using the module JYL took the time 
> to point out to you. There are examples there and everything. If you want 
> pre-written Ansible code without doing any research or leg work you should 
> look on galaxy.ansible.com. 
>
> And that is really weak criticizing someone that took more time to try to 
> solve your problem than you did. People are likely going to stop responding 
> to you after that comment.
>  
>
> On Wed, May 6, 2020 at 4:01 PM Quad Zero > 
> wrote:
>
>> Thanks for your reply but really is not helpful bud.
>>
>> This is like if i asked how i can get to a destination, you are telling 
>> me to go to a train or bus station. 
>>
>>
>> On Wednesday, May 6, 2020 at 7:32:08 AM UTC-4, Jean-Yves LENHOF wrote:
>>>
>>> Hi,
>>>
>>> There's a module to import key, please use it !
>>>
>>> https://docs.ansible.com/ansible/latest/modules/rpm_key_module.html
>>>
>>> Regards,
>>>
>>> JYL
>>> Le 06/05/2020 à 12:17, Quad Zero a écrit :
>>>
>>> Hi all,
>>>
>>> Thank you for your help in my last post. I have come quite a way (small 
>>> compared to many of you) but nevertheless making good progress each day. 
>>>
>>> I hit roadblocks quite a bit and thankfully google has helped me quite a 
>>> bit. I have come across this problem now which I hope some of you can 
>>> explain and then help me with finding a solution. This is my code so far:
>>>
>>> ---
>>> - hosts: all
>>>   serial: 3
>>>   become: yes
>>>   tasks:
>>> - name: ping all the machines
>>>   ping:
>>>
>>> - name: Import all GPG keys for repo
>>>   command: "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*"
>>>
>>>
>>> When I am trying to run the rpm --import as a command, I get this error 
>>> on my 3 test hosts:
>>> 1. What does it mean, why is this producing an error? I can enter this 
>>> directly as a command in shell and it works just fine, so where is Ansible 
>>> having issues?
>>> 2. How can I fix this and find a solution so that all my keys from the 
>>> pki directory is imported as I have a mixture of RHEL and CentOS systems?
>>>
>>> TASK [Import all GPG keys for repo] 
>>> *
>>> [WARNING]: Consider using the yum, dnf or zypper module rather than 
>>> running 'rpm'.  If you need to use command because yum, dnf or
>>> zypper is insufficient you can add 'warn: false' to this command task or 
>>> set 'command_warnings=False' in ansible.cfg to get rid of this
>>> message.
>>> fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["rpm", 
>>> "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.029904", 
>>> "end": "2020-05-06 05:08:49.909745", "msg": "non-zero return code", "rc": 
>>> 1, "start": "2020-05-06 05:08:49.879841", "stderr": "error: 
>>> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
>>> ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2)."], 
>>> "stdout": "", "stdout_lines": []}
>>> fatal: [testb_centos78]: FAILED! => {"changed": true, "cmd": ["rpm", 
>>> "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027775", 
>>> "end": "2020-05-06 05:08:50.031696", "msg": "non-zero return code", "rc": 
>>> 1, "start": "2020-05-06 05:08:50.003921", "stderr": "error: 
>>> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
>>> ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2)."], 
>>> "stdout": "", "stdout_lines": []}
>>> fatal: [testa_centos78]: FAILED! => {"changed": true, "cmd": ["rpm", 
>>> "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027843", 
>>> "end": "2020-05-06 05:08:50.035566", "msg": "non-zero return code", "rc": 
>>> 1, "start": "2020-05-06 05:08:50.007723", "stderr": "error: 
>>> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
>>> ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2)."], 
>>> "stdout": "", "stdout_lines": []}
>>>
>>> Thanks in advance everyone. 
>>> -- 
>>> 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 

Re: [ansible-project] Directories create twice

2020-05-07 Thread Quentin Aveno
Hi, thanks for your response.

I don't really understand this behavior. It's probably a syntax error 
(trailing slash or something like that, as you mentioned)

I ended up using :
- name: "Look for all files in services"
  find:
paths: "{{ local_tmp_dir.path }}"
file_type: file
recurse: yes
  register: local_modules_files

- debug:
var: local_modules_files

- name: "Create directory"
  file:
path: "{{ ( dest_directory +  '/' + ( item.path | 
relpath(local_tmp_dir.path) ) ) | dirname }}"
state: directory
recurse: yes
  loop: "{{ local_modules_files.files }}"

- name: "Copy"
  copy:
remote_src: yes
src: "{{ item.path }}"
dest: "{{ dest_directory }}/{{ item.path | 
relpath(local_tmp_dir.path) }}"
  loop: "{{ local_modules_files.files }}"

I looking for file only (not any files type) and I create the 
subdirectories first then copy files in it (that's answer my question and 
seems to be better). I have concern about ownership, but that do what I 
want to.


Le jeudi 7 mai 2020 12:00:27 UTC+2, Dick Visser a écrit :
>
> without actually looking into it, this does sound very much like a 
> (missing) trailing slash issue somewhere 
>
> On Thu, 7 May 2020 at 11:00, Quentin Aveno  > wrote: 
> > 
> > Hello ! 
> > 
> > I have an issue concerning modules find then copy (with relpath filter) 
> > 
> > I have a role : 
> > - name: "Test" 
> >   hosts: localhost 
> >   vars: 
> > archive_name: "/opt/archive.tgz" 
> > local_tmp_dir: 
> >   path: "/tmp/tmp" 
> > dest_directory: "" 
> >   tasks: 
> > - name: "[Module] Download and unarchive module" 
> >   unarchive: 
> > remote_src: yes 
> > src: "{{ archive_name }}" 
> > dest: "{{ local_tmp_dir.path }}" 
> > 
> > - name: "[Module] Recherche de tous les fichiers de la conf" 
> >   find: 
> > paths: "{{ local_tmp_dir.path }}" 
> > recurse: yes 
> > file_type: any 
> >   register: local_modules_files 
> > 
> > - name: "[Module] Deploy module in /" 
> >   copy: 
> > src: "{{ item.path }}" 
> > dest: "{{ dest_directory }}/{{ item.path | 
> relpath(local_tmp_dir.path) }}" 
> >   loop_control: 
> > label: "{{ item.path }}" 
> >   loop: "{{ local_modules_files.files }}" 
> > 
> > 
> > When I execute it, all seems to works well, but all the directories are 
> create twice and the files existed in all directories (which means that the 
> fs will be full very quickly) 
> > If in the tar I had : /etc/services/service1/script1 
> > It will created : 
> > - /etc/services/service1/script1 (This one is the good one) 
> > - /etc/etc/services/service1/script1 
> > - /etc/services/services/service1/script1 
> > - /etc/services/service1/service1/script1 
> > 
> > Did I miss something ? 
> > 
> > -- 
> > 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/d229d89e-9043-45a1-ab63-0680d2b96b42%40googlegroups.com.
>  
>
>
>
>
> -- 
> 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/28fe85a5-8420-4ceb-ab81-d3f678fe1624%40googlegroups.com.


Re: [ansible-project] Adding task output to a file in a loop

2020-05-07 Thread harry devine
Each time through the loop, will the registered output overwrite the
previous values?

Harry

On Wed, May 6, 2020 at 11:51 PM Brian Coca  wrote:

> I would use a template , you can use  the  registered results in a for
> loop inside jinja2.
>
>
>
> --
> --
> Brian Coca
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CACVha7fqrKTqfZKfWVT1ckTve-9m5n0GBEzYbt5SRKrmvPPU%3Dg%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/CALYKJ251BANPT2x%3D1vjCe-YNc6M9AsH%2BkzdAciBoB_qgeNQ%3D_g%40mail.gmail.com.


Re: [ansible-project] how can i execute the following oracle sql commands using ansible and get the value back to be stored in variable

2020-05-07 Thread Jean-Yves LENHOF

Hi,

Perhaps, you should have a look on these :

https://github.com/oravirt/ansible-oracle

https://github.com/oravirt/ansible-oracle-modules

A lot of works has been done here

If you don't want all of these, a step in the right direction here :

https://stackoverflow.com/questions/41796466/ansible-playbook-to-execute-oracle-script

Regards,


Le 28/02/2018 à 11:58, Gopi Krishna a écrit :

HI,

MY playbook:

sample.sh:
. /u05/oracle/VISEBS/12.1.0/VISEBS_sal-devtl10.env
val='v$archived_log'
R=`sqlplus '/as sysdba'< 0;
exit;
EOF`

echo $R


I am trying to achieve the same through ansible using shell command, 
but im getting the error


- hosts: source
  tasks:
        - include_vars: sql.yml
        - shell: |
                . /u05/oracle/VISEBS/12.1.0/VISEBS_sal-devtl10.env
                val='v$archived_log'
                R=`sqlplus '/as sysdba' <<-EOF
                set numw 1 lines 80 pages 0;
                select max(NEXT_CHANGE#) "RMAN_SCN" from $val  where 
BACKUP_COUNT > 0;

                exit;
                EOF`
                echo $R
          register: cmd
        - debug:
                msg: "{{cmd}}"

error:
TASK [debug] 


ok: [10.210.8.149] => {
    "msg": {
        "changed": true,
        "cmd": ". /u05/oracle/VISEBS/12.1.0/VISEBS_sal-devtl10.env\n 
val='v$archived_log'\n R=`sqlplus '/as sysdba' <<-EOF\n set numw 1 
lines 80 pages 0;\n select max(NEXT_CHANGE#) \"RMAN_SCN\" from $val 
where BACKUP_COUNT > 0;\n exit;\n EOF`\n echo $R",

        "delta": "0:00:01.031347",
        "end": "2018-02-28 10:15:49.032656",
        "failed": false,
        "rc": 0,
        "start": "2018-02-28 10:15:48.001309",
        "stderr": "/bin/bash: line 10: warning: here-document at line 
6 delimited by end-of-file (wanted `EOF')",

        "stderr_lines": [
            "/bin/bash: line 10: warning: here-document at line 6 
delimited by end-of-file (wanted `EOF')"

        ],
        "stdout": "SQL*Plus: Release 12.1.0.2.0 Production on Wed Feb 
28 10:15:48 2018 Copyright (c) 1982, 2014, Oracle. All rights 
reserved. ERROR: ORA-01017: invalid username/password; logon denied 
Enter user-name: SP2-0306: Invalid option. Usage: CONN[ECT] 
[{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] 
[edition=value]] where  ::= 
[/][@]  ::= 
[][/][@] Enter 
user-name: SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} 
[AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] 
where  ::= [/][@] 
 ::= 
[][/][@] SP2-0157: 
unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus",

        "stdout_lines": [
            "SQL*Plus: Release 12.1.0.2.0 Production on Wed Feb 28 
10:15:48 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. 
ERROR: ORA-01017: invalid username/password; logon denied Enter 
user-name: SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} 
[AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] 
where  ::= [/][@] 
 ::= 
[][/][@] Enter 
user-name: SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} 
[AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] 
where  ::= [/][@] 
 ::= 
[][/][@] SP2-0157: 
unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus"

        ]
    }
}


some one help me
--
You received this message because you are subscribed to the Google 
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to ansible-project+unsubscr...@googlegroups.com 
.
To post to this group, send email to ansible-project@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e31a47af-cc16-4fe0-ab75-80e9a58dfe13%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ec6a2643-701d-6c3c-936d-ea479d07452a%40lenhof.eu.org.


[ansible-project] Re: how can i execute the following oracle sql commands using ansible and get the value back to be stored in variable

2020-05-07 Thread vishal natekar
Hey, wondering if you found the solution to this. 

On Wednesday, February 28, 2018 at 10:58:21 AM UTC, Gopi Krishna wrote:
>
> HI,
>
> MY playbook:
>
> sample.sh:
> . /u05/oracle/VISEBS/12.1.0/VISEBS_sal-devtl10.env
> val='v$archived_log'
> R=`sqlplus '/as sysdba'< set numw 1 lines 80 pages 0;
> select max(NEXT_CHANGE#) "RMAN_SCN" from $val  where BACKUP_COUNT > 0;
> exit;
> EOF`
>
> echo $R
>
>
> I am trying to achieve the same through ansible using shell command, but 
> im getting the error
>
> - hosts: source
>   tasks:
> - include_vars: sql.yml
> - shell: |
> . /u05/oracle/VISEBS/12.1.0/VISEBS_sal-devtl10.env
> val='v$archived_log'
> R=`sqlplus '/as sysdba' <<-EOF
> set numw 1 lines 80 pages 0;
> select max(NEXT_CHANGE#) "RMAN_SCN" from $val  where 
> BACKUP_COUNT > 0;
> exit;
> EOF`
> echo $R
>   register: cmd
> - debug:
> msg: "{{cmd}}"
>
> error: 
> TASK [debug] 
> 
> ok: [10.210.8.149] => {
> "msg": {
> "changed": true,
> "cmd": ". /u05/oracle/VISEBS/12.1.0/VISEBS_sal-devtl10.env\n 
> val='v$archived_log'\n R=`sqlplus '/as sysdba' <<-EOF\n set numw 1 lines 80 
> pages 0;\n select max(NEXT_CHANGE#) \"RMAN_SCN\" from $val where 
> BACKUP_COUNT > 0;\n exit;\n EOF`\n echo $R",
> "delta": "0:00:01.031347",
> "end": "2018-02-28 10:15:49.032656",
> "failed": false,
> "rc": 0,
> "start": "2018-02-28 10:15:48.001309",
> "stderr": "/bin/bash: line 10: warning: here-document at line 6 
> delimited by end-of-file (wanted `EOF')",
> "stderr_lines": [
> "/bin/bash: line 10: warning: here-document at line 6 
> delimited by end-of-file (wanted `EOF')"
> ],
> "stdout": "SQL*Plus: Release 12.1.0.2.0 Production on Wed Feb 28 
> 10:15:48 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. ERROR: 
> ORA-01017: invalid username/password; logon denied Enter user-name: 
> SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} [AS 
> {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] where 
>  ::= [/][@]  ::= 
> [][/][@] Enter 
> user-name: SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} [AS 
> {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] where 
>  ::= [/][@]  ::= 
> [][/][@] SP2-0157: 
> unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus",
> "stdout_lines": [
> "SQL*Plus: Release 12.1.0.2.0 Production on Wed Feb 28 
> 10:15:48 2018 Copyright (c) 1982, 2014, Oracle. All rights reserved. ERROR: 
> ORA-01017: invalid username/password; logon denied Enter user-name: 
> SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} [AS 
> {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] where 
>  ::= [/][@]  ::= 
> [][/][@] Enter 
> user-name: SP2-0306: Invalid option. Usage: CONN[ECT] [{logon|/|proxy} [AS 
> {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM}] [edition=value]] where 
>  ::= [/][@]  ::= 
> [][/][@] SP2-0157: 
> unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus"
> ]
> }
> }
>
>
> some one help me
>

-- 
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/95d2fb25-637a-4298-b3ec-477081ce2165%40googlegroups.com.


Re: [ansible-project] Directories create twice

2020-05-07 Thread Dick Visser
without actually looking into it, this does sound very much like a
(missing) trailing slash issue somewhere

On Thu, 7 May 2020 at 11:00, Quentin Aveno  wrote:
>
> Hello !
>
> I have an issue concerning modules find then copy (with relpath filter)
>
> I have a role :
> - name: "Test"
>   hosts: localhost
>   vars:
> archive_name: "/opt/archive.tgz"
> local_tmp_dir:
>   path: "/tmp/tmp"
> dest_directory: ""
>   tasks:
> - name: "[Module] Download and unarchive module"
>   unarchive:
> remote_src: yes
> src: "{{ archive_name }}"
> dest: "{{ local_tmp_dir.path }}"
>
> - name: "[Module] Recherche de tous les fichiers de la conf"
>   find:
> paths: "{{ local_tmp_dir.path }}"
> recurse: yes
> file_type: any
>   register: local_modules_files
>
> - name: "[Module] Deploy module in /"
>   copy:
> src: "{{ item.path }}"
> dest: "{{ dest_directory }}/{{ item.path | 
> relpath(local_tmp_dir.path) }}"
>   loop_control:
> label: "{{ item.path }}"
>   loop: "{{ local_modules_files.files }}"
>
>
> When I execute it, all seems to works well, but all the directories are 
> create twice and the files existed in all directories (which means that the 
> fs will be full very quickly)
> If in the tar I had : /etc/services/service1/script1
> It will created :
> - /etc/services/service1/script1 (This one is the good one)
> - /etc/etc/services/service1/script1
> - /etc/services/services/service1/script1
> - /etc/services/service1/service1/script1
>
> Did I miss something ?
>
> --
> 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/d229d89e-9043-45a1-ab63-0680d2b96b42%40googlegroups.com.



-- 
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/CAL8fbwO2hC1su5_g_XYa%3DXRZ%2BkPx8GE76K3f-N6DPcRjGg55BA%40mail.gmail.com.


Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Vladimir Botka
On Thu, 7 May 2020 02:25:16 -0700 (PDT)
דודו דודו  wrote:

> Using domain_name | default("") == ""  skip the task no matter if i have 
> value or not 

This is not what I see. Both the comparison to an empty string and testing
the length should work. For example

 hosts: localhost
  tasks:
- debug:
msg: Non-existent or empty
  when: domain_name|default("") == ""
- debug:
msg: Non-existent or empty
  when: domain_name|default("")|length == 0
- set_fact:
domain_name: example.com
- debug:
msg: Non-existent or empty
  when: domain_name|default("") == ""
- debug:
msg: Non-existent or empty
  when: domain_name|default("")|length == 0

gives

  TASK [debug] 
  ok: [localhost] => {
  "msg": "Non-existent or empty"
  }

  TASK [debug] 
  ok: [localhost] => {
  "msg": "Non-existent or empty"
  }

  TASK [set_fact] ***
  ok: [localhost]

  TASK [debug] 
  skipping: [localhost]

  TASK [debug] 
  skipping: [localhost]


The comparison to an empty string is deprecated.

HTH,

-vlado

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


pgp0r6ysRCHD3.pgp
Description: OpenPGP digital signature


[ansible-project] Re: vmotion condition

2020-05-07 Thread Mani
Real-time memory and datastore calculation using the pre-defined module for 
VMware.Please provide if this is achievable in Ansible or not.

Thanks,
Mani

On Thursday, 30 April 2020 00:26:53 UTC+5:30, Mani wrote:
>
> I am trying to perform vmotion of multiple VMs between 2 ESXi hosts using 
> the vmare_vmotion module. We need to set a cap for memory utilization of 
> the destination host to <= 70% and the storage utilization to <= 90%. 
>
> Required result: VMs have to be migrated until the memory and storage 
> utilization has reached. The loop should stop VM migration once the memory 
> & storage threshold has reached.
>
> - name: Perform storage vMotion and host vMotion of virtual machine
>   vmware_vmotion:
> hostname: "{{ running_host }}"
> username: "{{ esxi_user }}"
> password: "{{ esxi_pass }}"
> validate_certs: no
> vm_name: "{{ item.guest_name }}"
> destination_host: "{{ destination_host }}"
> destination_datastore: "{{ item.name }}"
>   delegate_to: localhost
>   with_nested:
> - "{{vm_info.virtual_machines}}"
> - "{{ansible_datastore}}"
>
> Any inputs is highly appreciated.
>

-- 
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/9c299399-230b-4ebf-baf2-d946d63243cb%40googlegroups.com.


Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Vladimir Botka
On Thu, 7 May 2020 02:25:16 -0700 (PDT)
דודו דודו  wrote:

> Using domain_name | default("") == ""  skip the task no matter if i have 
> value or not 

Compare the lenght to 0 then

when: domain_name|default("")|length == 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/20200507114857.473ee775%40gmail.com.


pgpoPqgqUvwIR.pgp
Description: OpenPGP digital signature


Re: [ansible-project] How to assign random name for vmware snapshot?

2020-05-07 Thread Mani
Thank you, Abhijeet. That worked!!

On Thursday, 7 May 2020 14:16:53 UTC+5:30, Abhijeet Kasurde wrote:
>
> You can use filters - 
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
>
> Either - "{{ hostname | to_uuid }}" or  "{{ '%Y_%m_%d_%H_%M_%S' | strftime 
> }}"
>
> On Thu, May 7, 2020 at 2:00 PM Mani > 
> wrote:
>
>> I am a newbie to ansible and I am trying to take a snapshot of multiple 
>> VM's with a random snapshot name including the VM name (vmname + random 
>> number or timestamp). 
>>
>> I am able to take snapshot using the VM name with the below code:
>>
>> ---
>> - name: Gather all registered virtual machines
>>   vmware_vm_info:
>> hostname: '{{ running_host }}'
>> username: '{{ esxi_user }}'
>> password: '{{ esxi_pass }}'
>>   delegate_to: localhost
>>   register: vminfo
>>
>> - name: Create a snapshot
>>   vmware_guest_snapshot:
>> hostname: "{{ vcenter_server }}"
>> username: "{{ vcenter_user }}"
>> password: "{{ vcenter_pass }}"
>> datacenter: 'VDC'
>> folder: 'VDC/vm/'
>> name: "{{ item.guest_name }}"
>> state: present
>> snapshot_name: "{{ item.guest_name }}"
>>   with_items:
>> - "{{ vminfo.virtual_machines }}"
>>
>> Please provide your inputs.
>>
>> -- 
>> 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/8c90bfb1-30ff-4f56-b1db-42320a9e55c8%40googlegroups.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/f8fab4c3-daee-4121-af73-10f02d28f363%40googlegroups.com.


Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread דודו דודו
Using domain_name | default("") == ""  skip the task no matter if i have 
value or not 

On Thursday, May 7, 2020 at 11:42:03 AM UTC+3, Stefan Hornburg (Racke) 
wrote:
>
> On 5/7/20 10:35 AM, דודו דודו wrote: 
> > i have a variable (domain_name) located on external YML file,  
> > I wish to run a task in case the variable is empty.   From some reason, 
> it is always skipping no matter if i have a 
> > value or not  
> > 
>
> You are doing a string test on an undefined variable, try (untested): 
>
> when: domain_name | default("") == "" 
>
> Regards 
> Racke 
>
> > 
> > *External Yaml* 
> > 
> > 
> > domain_name: 
> > ldap_server_hostname: 10.168.233.77  # Ip can be used as well 
> > ldap_port: 389 
> > 
> > 
> > 
> > *Playbook* 
> > 
> > 
> > - hosts: k8s_master 
> >   become: true 
> >   gather_facts: true 
> >   vars_files: ./keycloak_configuration.yml 
> >   tasks: 
> > 
> > 
> > - debug: 
> >   msg: "{{domain_name}}" 
> > 
> > ### Copy realm for none LDAP Support ### 
> > 
> > - name: Copy realm  LDAP Support 
> > copy: 
> >   src: "{{ realm_src_path }}{{ realm_template_file_name }}" 
> > dest: "{{ realm_dest_path }}{{ realm_updated_file_name }}" 
> > when: domain_name == "" 
> > 
> > 
> > *result * 
> > 
> > TASK [debug] 
> > 
> **
>  
>
> > task path: /data/ansible/new2_keycloak/create-realm-secert.yml:18 
> > ok: [10.164.237.140] => { 
> > "msg": null 
> > } 
> > Read vars_file './keycloak_configuration.yml' 
> > 
> > TASK [Copy realm  LDAP Support] 
> > 
> ***
>  
>
> > task path: /data/ansible/new2_keycloak/create-realm-secert.yml:23 
> > skipping: [10.164.237.140] => { 
> > "changed": false, 
> > "skip_reason": "Conditional result was False" 
> > } 
> > META: ran handlers 
> > META: ran handlers 
> > 
> > 
> > *result *- When updating domain_name with *test *value 
> > 
> > 
> > TASK [debug] 
> > 
> **
>  
>
> > task path: /data/ansible/new2_keycloak/create-realm-secert.yml:18 
> > ok: [10.164.237.140] => { 
> > "msg": "test" 
> > } 
> > Read vars_file './keycloak_configuration.yml' 
> > 
> > TASK [Copy realm  LDAP Support] 
> > 
> ***
>  
>
> > task path: /data/ansible/new2_keycloak/create-realm-secert.yml:23 
> > skipping: [10.164.237.140] => { 
> > "changed": false, 
> > "skip_reason": "Conditional result was False" 
> > } 
> > META: ran handlers 
> > META: ran handlers 
> > 
> > 
> > 
> > 
> > -- 
> > 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/556bc277-860c-4c09-82b5-6b0183e13d81%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/556bc277-860c-4c09-82b5-6b0183e13d81%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/e926b592-990c-4ec4-a9a8-c5f8e703322a%40googlegroups.com.


Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread דודו דודו
when using  *domain_name|default("")|length > 0  *and the paramter is empry 
i'm geeting the follwoing error message.  When  the parameter include value 
it is working 

fatal: [10.164.237.140]: FAILED! => {"msg": "The conditional check 
'domain_name |  default(\"\") | length > 0' failed. The error was: 
Unexpected templating type error occurred on ({% if domain_name |  
default(\"\") | length > 0 %} True {% else %} False {% endif %}): object of 
type 'NoneType' has no len()\n\nThe error appears to be in 
'/data/ansible/new2_keycloak/create-realm-secert.yml': line 13, column 5, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\n  - name: Copy realm no 
LDAP Support\n^ here\n"}

On Thursday, May 7, 2020 at 11:52:32 AM UTC+3, Vladimir Botka wrote:
>
> > when: domain_name | default("") == "" 
>
> Don't compare to empty string. Test the length instead 
>
> https://github.com/ansible/ansible-lint/blob/master/lib/ansiblelint/rules/ComparisonToEmptyStringRule.py
>  
>
>   when: domain_name|default("")|length > 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/d60f8dee-4016-40be-8f1e-6fb1258038ea%40googlegroups.com.


[ansible-project] Re: "failed to open a SFTP connection (Garbage packet received)"

2020-05-07 Thread Dave Hodgkinson

Never mind. .bashrc was outputting something and that blew sftp up.

-- 
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/76b3241a-1a7f-4d2b-8c65-9a5d34d3cbaa%40googlegroups.com.


[ansible-project] Directories create twice

2020-05-07 Thread Quentin Aveno
Hello !

I have an issue concerning modules find then copy (with relpath filter)

I have a role :
- name: "Test"
  hosts: localhost
  vars:
archive_name: "/opt/archive.tgz"
local_tmp_dir:
  path: "/tmp/tmp"
dest_directory: ""
  tasks:
- name: "[Module] Download and unarchive module"
  unarchive:
remote_src: yes
src: "{{ archive_name }}"
dest: "{{ local_tmp_dir.path }}"

- name: "[Module] Recherche de tous les fichiers de la conf"
  find:
paths: "{{ local_tmp_dir.path }}"
recurse: yes
file_type: any
  register: local_modules_files

- name: "[Module] Deploy module in /"
  copy:
src: "{{ item.path }}"
dest: "{{ dest_directory }}/{{ item.path | 
relpath(local_tmp_dir.path) }}"
  loop_control:
label: "{{ item.path }}"
  loop: "{{ local_modules_files.files }}"


When I execute it, all seems to works well, but all the directories are 
create twice and the files existed in all directories (which means that the 
fs will be full very quickly)
If in the tar I had : /etc/services/service1/script1
It will created :
- /etc/services/service1/script1 (This one is the good one)
- /etc/etc/services/service1/script1
- /etc/services/services/service1/script1
- /etc/services/service1/service1/script1

Did I miss something ?

-- 
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/d229d89e-9043-45a1-ab63-0680d2b96b42%40googlegroups.com.


[ansible-project] "failed to open a SFTP connection (Garbage packet received)"

2020-05-07 Thread Dave Hodgkinson
I'm tring to run our corporate ansible setup on my FC31 laptop. In the 
"staging" configuration, main.yml, I have hosts: localhost. My ssh key is 
in root's authorized_keys file.

I run and get:

ansible-playbook main.yml 
 
PLAY [Common tasks (various inc auth, firewall and update)] 
 
 
TASK [Gathering Facts] 
* 
[WARNING]: Unhandled error in Python interpreter discovery for host 
localhost: 
unexpected output from Python interpreter discovery 
fatal: [localhost]: FAILED! => {"msg": "failed to open a SFTP connection 
(Garbage packet received)"} 
 
PLAY RECAP 
* 
localhost  : ok=0changed=0unreachable=0
failed=1skipped=0rescued=0ignored=0


Any idea what's going on? There's no mention of sftp in my playbooks, I 
have vsftp installed.

-- 
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/04b9cb65-9d50-4fd1-8ccf-12727205c42d%40googlegroups.com.


Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Vladimir Botka
> when: domain_name | default("") == ""

Don't compare to empty string. Test the length instead
https://github.com/ansible/ansible-lint/blob/master/lib/ansiblelint/rules/ComparisonToEmptyStringRule.py

  when: domain_name|default("")|length > 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/20200507105215.53501a42%40gmail.com.


pgpV1kpeZJtT6.pgp
Description: OpenPGP digital signature


Re: [ansible-project] How to assign random name for vmware snapshot?

2020-05-07 Thread Abhijeet Kasurde
You can use filters -
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html

Either - "{{ hostname | to_uuid }}" or  "{{ '%Y_%m_%d_%H_%M_%S' | strftime
}}"

On Thu, May 7, 2020 at 2:00 PM Mani  wrote:

> I am a newbie to ansible and I am trying to take a snapshot of multiple
> VM's with a random snapshot name including the VM name (vmname + random
> number or timestamp).
>
> I am able to take snapshot using the VM name with the below code:
>
> ---
> - name: Gather all registered virtual machines
>   vmware_vm_info:
> hostname: '{{ running_host }}'
> username: '{{ esxi_user }}'
> password: '{{ esxi_pass }}'
>   delegate_to: localhost
>   register: vminfo
>
> - name: Create a snapshot
>   vmware_guest_snapshot:
> hostname: "{{ vcenter_server }}"
> username: "{{ vcenter_user }}"
> password: "{{ vcenter_pass }}"
> datacenter: 'VDC'
> folder: 'VDC/vm/'
> name: "{{ item.guest_name }}"
> state: present
> snapshot_name: "{{ item.guest_name }}"
>   with_items:
> - "{{ vminfo.virtual_machines }}"
>
> Please provide your inputs.
>
> --
> 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/8c90bfb1-30ff-4f56-b1db-42320a9e55c8%40googlegroups.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/CAFwWkHo-bap3nK8%2BWBwQFOQfoiTkfkL4B_D95eL1Zz75WHguzQ%40mail.gmail.com.


Re: [ansible-project] Problem using when condition for empty variable

2020-05-07 Thread Stefan Hornburg (Racke)
On 5/7/20 10:35 AM, דודו דודו wrote:
> i have a variable (domain_name) located on external YML file, 
> I wish to run a task in case the variable is empty.   From some reason, it is 
> always skipping no matter if i have a
> value or not 
> 

You are doing a string test on an undefined variable, try (untested):

when: domain_name | default("") == ""

Regards
Racke

> 
> *External Yaml*
> 
> 
> domain_name:
> ldap_server_hostname: 10.168.233.77  # Ip can be used as well
> ldap_port: 389
> 
> 
> 
> *Playbook*
> 
> 
> - hosts: k8s_master
>   become: true
>   gather_facts: true
>   vars_files: ./keycloak_configuration.yml
>   tasks:
> 
> 
> - debug:
>   msg: "{{domain_name}}"
> 
> ### Copy realm for none LDAP Support ###
> 
> - name: Copy realm  LDAP Support
> copy:
>   src: "{{ realm_src_path }}{{ realm_template_file_name }}"
> dest: "{{ realm_dest_path }}{{ realm_updated_file_name }}"
> when: domain_name == ""
> 
> 
> *result *
> 
> TASK [debug]
> **
> task path: /data/ansible/new2_keycloak/create-realm-secert.yml:18
> ok: [10.164.237.140] => {
>     "msg": null
> }
> Read vars_file './keycloak_configuration.yml'
> 
> TASK [Copy realm  LDAP Support]
> ***
> task path: /data/ansible/new2_keycloak/create-realm-secert.yml:23
> skipping: [10.164.237.140] => {
>     "changed": false,
>     "skip_reason": "Conditional result was False"
> }
> META: ran handlers
> META: ran handlers
> 
> 
> *result *- When updating domain_name with *test *value
> 
> 
> TASK [debug]
> **
> task path: /data/ansible/new2_keycloak/create-realm-secert.yml:18
> ok: [10.164.237.140] => {
>     "msg": "test"
> }
> Read vars_file './keycloak_configuration.yml'
> 
> TASK [Copy realm  LDAP Support]
> ***
> task path: /data/ansible/new2_keycloak/create-realm-secert.yml:23
> skipping: [10.164.237.140] => {
>     "changed": false,
>     "skip_reason": "Conditional result was False"
> }
> META: ran handlers
> META: ran handlers
> 
> 
> 
> 
> -- 
> 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/556bc277-860c-4c09-82b5-6b0183e13d81%40googlegroups.com
> .


-- 
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/c8fbfc08-24f6-5b47-589b-2558fe25738d%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Problem using when condition for empty variable

2020-05-07 Thread דודו דודו
i have a variable (domain_name) located on external YML file, 
I wish to run a task in case the variable is empty.   From some reason, it 
is always skipping no matter if i have a value or not 


*External Yaml*


domain_name:
ldap_server_hostname: 10.168.233.77  # Ip can be used as well
ldap_port: 389



*Playbook*


- hosts: k8s_master
  become: true
  gather_facts: true
  vars_files: ./keycloak_configuration.yml
  tasks:


  - debug:
  msg: "{{domain_name}}"

### Copy realm for none LDAP Support ###

  - name: Copy realm  LDAP Support
copy:
  src: "{{ realm_src_path }}{{ realm_template_file_name }}"
  dest: "{{ realm_dest_path }}{{ realm_updated_file_name }}"
when: domain_name == ""


*result *

TASK [debug] 
**
task path: /data/ansible/new2_keycloak/create-realm-secert.yml:18
ok: [10.164.237.140] => {
"msg": null
}
Read vars_file './keycloak_configuration.yml'

TASK [Copy realm  LDAP Support] 
***
task path: /data/ansible/new2_keycloak/create-realm-secert.yml:23
skipping: [10.164.237.140] => {
"changed": false,
"skip_reason": "Conditional result was False"
}
META: ran handlers
META: ran handlers


*result *- When updating domain_name with *test *value


TASK [debug] 
**
task path: /data/ansible/new2_keycloak/create-realm-secert.yml:18
ok: [10.164.237.140] => {
"msg": "test"
}
Read vars_file './keycloak_configuration.yml'

TASK [Copy realm  LDAP Support] 
***
task path: /data/ansible/new2_keycloak/create-realm-secert.yml:23
skipping: [10.164.237.140] => {
"changed": false,
"skip_reason": "Conditional result was False"
}
META: ran handlers
META: ran handlers




-- 
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/556bc277-860c-4c09-82b5-6b0183e13d81%40googlegroups.com.


[ansible-project] How to assign random name for vmware snapshot?

2020-05-07 Thread Mani
I am a newbie to ansible and I am trying to take a snapshot of multiple 
VM's with a random snapshot name including the VM name (vmname + random 
number or timestamp). 

I am able to take snapshot using the VM name with the below code:

---
- name: Gather all registered virtual machines
  vmware_vm_info:
hostname: '{{ running_host }}'
username: '{{ esxi_user }}'
password: '{{ esxi_pass }}'
  delegate_to: localhost
  register: vminfo

- name: Create a snapshot
  vmware_guest_snapshot:
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
datacenter: 'VDC'
folder: 'VDC/vm/'
name: "{{ item.guest_name }}"
state: present
snapshot_name: "{{ item.guest_name }}"
  with_items:
- "{{ vminfo.virtual_machines }}"

Please provide your inputs.

-- 
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/8c90bfb1-30ff-4f56-b1db-42320a9e55c8%40googlegroups.com.


Re: [ansible-project] rpm--import issues

2020-05-07 Thread Stefan Hornburg (Racke)
On 5/7/20 1:01 AM, Quad Zero wrote:
> Thanks for your reply but really is not helpful bud.
> 
> This is like if i asked how i can get to a destination, you are telling me to 
> go to a train or bus station.
> 

That was a bad move from you if you ask me.

Regards
  Racke
> 
> On Wednesday, May 6, 2020 at 7:32:08 AM UTC-4, Jean-Yves LENHOF wrote:
> 
> Hi,
> 
> There's a module to import key, please use it !
> 
> https://docs.ansible.com/ansible/latest/modules/rpm_key_module.html
> 
> 
> Regards,
> 
> JYL
> 
> Le 06/05/2020 à 12:17, Quad Zero a écrit :
>> Hi all,
>>
>> Thank you for your help in my last post. I have come quite a way (small 
>> compared to many of you) but nevertheless
>> making good progress each day.
>>
>> I hit roadblocks quite a bit and thankfully google has helped me quite a 
>> bit. I have come across this problem now
>> which I hope some of you can explain and then help me with finding a 
>> solution. This is my code so far:
>>
>> ---
>> - hosts: all
>>   serial: 3
>>   become: yes
>>   tasks:
>>     - name: ping all the machines
>>   ping:
>>
>>     - name: Import all GPG keys for repo
>>   command: "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*"
>>
>>
>> When I am trying to run the rpm --import as a command, I get this error 
>> on my 3 test hosts:
>> 1. What does it mean, why is this producing an error? I can enter this 
>> directly as a command in shell and it works
>> just fine, so where is Ansible having issues?
>> 2. How can I fix this and find a solution so that all my keys from the 
>> pki directory is imported as I have a
>> mixture of RHEL and CentOS systems?
>>
>> TASK [Import all GPG keys for repo]
>> 
>> *
>> [WARNING]: Consider using the yum, dnf or zypper module rather than 
>> running 'rpm'.  If you need to use command
>> because yum, dnf or
>> zypper is insufficient you can add 'warn: false' to this command task or 
>> set 'command_warnings=False' in
>> ansible.cfg to get rid of this
>> message.
>> fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["rpm", 
>> "--import", "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"],
>> "delta": "0:00:00.029904", "end": "2020-05-06 05:08:49.909745", "msg": 
>> "non-zero return code", "rc": 1, "start":
>> "2020-05-06 05:08:49.879841", "stderr": "error: 
>> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).",
>> "stderr_lines": ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read 
>> failed(2)."], "stdout": "", "stdout_lines": []}
>> fatal: [testb_centos78]: FAILED! => {"changed": true, "cmd": ["rpm", 
>> "--import",
>> "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027775", "end": 
>> "2020-05-06 05:08:50.031696", "msg":
>> "non-zero return code", "rc": 1, "start": "2020-05-06 05:08:50.003921", 
>> "stderr": "error:
>> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
>> ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*:
>> import read failed(2)."], "stdout": "", "stdout_lines": []}
>> fatal: [testa_centos78]: FAILED! => {"changed": true, "cmd": ["rpm", 
>> "--import",
>> "/etc/pki/rpm-gpg/RPM-GPG-KEY-*"], "delta": "0:00:00.027843", "end": 
>> "2020-05-06 05:08:50.035566", "msg":
>> "non-zero return code", "rc": 1, "start": "2020-05-06 05:08:50.007723", 
>> "stderr": "error:
>> /etc/pki/rpm-gpg/RPM-GPG-KEY-*: import read failed(2).", "stderr_lines": 
>> ["error: /etc/pki/rpm-gpg/RPM-GPG-KEY-*:
>> import read failed(2)."], "stdout": "", "stdout_lines": []}
>>
>> Thanks in advance everyone.
>> -- 
>> 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/cf399d8a-bba9-49b8-afe9-6d07516eb99f%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/ae9486f0-9769-4363-8803-7060273a6878%40googlegroups.com
> .


-- 
Ecommerce