[ansible-project] Adding body: to uri: task results in Status code was -1 and not [200]: An unknown error occurred: unhashable type

2020-02-11 Thread Stephen Elves
Hi,

Tearing what little hair I have left:

This is the fragment of the playbook:
- name: create new RE if RE doesn't exist
uri:
url: https://api.eu.cloud.talend.com/tmc/v1.3/runtimes/remote-engines
method: POST
headers:
Authorization: Basic {{talend_personal_access_token}}
Accept: application/json
status-code: 201
body-format: json
* body:*
* name: "{{RE_name}}"*
register: new_RE_response
when: check_response.json[0].id is undefined

If I remove the body: part then, well it doesn't work but the failure is a 
response code from the webservice (415), with it in I get: 

{ "status": -1, "exception": "Traceback (most recent call last):\n File 
\"/tmp/ansible_uri_payload_nEptqB/ansible_uri_payload.zip/ansible/module_utils/urls.py\",
 
line 1359, in fetch_url\n unix_socket=unix_socket)\n File 
\"/tmp/ansible_uri_payload_nEptqB/ansible_uri_payload.zip/ansible/module_utils/urls.py\",
 
line 1257, in open_url\n use_gssapi=use_gssapi, unix_socket=unix_socket)\n 
File 
\"/tmp/ansible_uri_payload_nEptqB/ansible_uri_payload.zip/ansible/module_utils/urls.py\",
 
line 1163, in open\n r = urllib_request.urlopen(*urlopen_args)\n File 
\"/usr/lib64/python2.7/urllib2.py\", line 154, in urlopen\n return 
opener.open(url, data, timeout)\n File \"/usr/lib64/python2.7/urllib2.py\", 
line 431, in open\n response = self._open(req, data)\n File 
\"/usr/lib64/python2.7/urllib2.py\", line 449, in _open\n '_open', req)\n 
File \"/usr/lib64/python2.7/urllib2.py\", line 409, in _call_chain\n result 
= func(*args)\n File 
\"/tmp/ansible_uri_payload_nEptqB/ansible_uri_payload.zip/ansible/module_utils/urls.py\",
 
line 356, in https_open\n return self.do_open(CustomHTTPSConnection, req)\n 
File \"/usr/lib64/python2.7/urllib2.py\", line 1211, in do_open\n 
h.request(req.get_method(), req.get_selector(), req.data, headers)\n File 
\"/usr/lib64/python2.7/httplib.py\", line 1056, in request\n 
self._send_request(method, url, body, headers)\n File 
\"/usr/lib64/python2.7/httplib.py\", line 1090, in _send_request\n 
self.endheaders(body)\n File \"/usr/lib64/python2.7/httplib.py\", line 
1052, in endheaders\n self._send_output(message_body)\n File 
\"/usr/lib64/python2.7/httplib.py\", line 894, in _send_output\n 
self.send(message_body)\n File \"/usr/lib64/python2.7/httplib.py\", line 
866, in send\n self.sock.sendall(data)\n File 
\"/usr/lib64/python2.7/ssl.py\", line 744, in sendall\n v = 
self.send(data[count:])\nTypeError: unhashable type\n", "url": 
"https://api.eu.cloud.talend.com/tmc/v1.3/runtimes/remote-engines;, 
"changed": false, "elapsed": 1, "content": "", "invocation": { 
"module_args": { "directory_mode": null, "force": false, "remote_src": 
null, "status_code": [ 200 ], "follow": false, "owner": null, 
"body_format": "raw", "body-format": "json", "client_key": null, "group": 
null, "use_proxy": true, "headers": { "Accept": "application/json", 
"Authorization": "Basic " }, "unsafe_writes": null, "setype": 
null, "content": null, "serole": null, "follow_redirects": "safe", 
"return_content": false, "client_cert": null, "body": { "name": 
"RHEL_X.X.X.X_AZGLGBNEVTA30_PRODUCTION_C4E" }, "timeout": 30, "src": null, 
"dest": null, "selevel": null, "force_basic_auth": true, "removes": null, 
"http_agent": "ansible-httpget", "regexp": null, "status-code": 201, 
"url_password": null, "url": 
"https://api.eu.cloud.talend.com/tmc/v1.3/runtimes/remote-engines;, 
"validate_certs": true, "seuser": null, "method": "POST", "creates": null, 
"unix_socket": null, "delimiter": null, "mode": null, "url_username": null, 
"attributes": null, "backup": null } }, "redirected": false, * "msg": 
"Status code was -1 and not [200]: An unknown error occurred: unhashable 
type",* "_ansible_no_log": false } 

For reference:
ansible --version ansible 2.9.4 config file = /etc/ansible/ansible.cfg 
configured module search path = 
[u'/home/jason_ho/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules'] ansible python module location = 
/usr/lib/python2.7/site-packages/ansible executable location = 
/usr/bin/ansible python version = 2.7.5 (default, Jun 11 2019, 14:33:56) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] 

This is running through AWX 9.1.1

Am I doing something wrong or have I ran into a bug?

Cheers

Stephen

-- 
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/3d20e218-c443-4c73-9bf4-505874d2e698%40googlegroups.com.


[ansible-project] use rules from different git repos/locations

2020-02-11 Thread sanctc
Hi Folks,
Can I use roles from several different git repos/locations to single 
ansible?
e.g. 
---
- hosts: myhost
  roles:
- role1: '/path/to/my/roles/common'
- role2: '/usr1/to/my/roles/client'
- role3: '/usrpath/to/my/roles/server'

What would be the best way to use roles from different locations?

Thanks,
Santosh

-- 
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/3031f4c9-ea37-4032-b971-4668b5e55e7c%40googlegroups.com.


[ansible-project] Use rules from different git repo

2020-02-11 Thread Santosh Behera
Hi Folks,
Can I use rules from several different git repo/location to single ansible?
e.g. 
---
- hosts: myhost
  roles:
- role1: '/path/to/my/roles/common'
- role2: '/usr1/to/my/roles/client'
- role3: '/usrpath/to/my/roles/server'

What would be the best way to use roles from different locations?

Thanks,
Santosh

-- 
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/314d537a-bffa-4f96-905a-4acd8a5da577%40googlegroups.com.


[ansible-project] Ansible Vault online tool for encrypt/decrypt

2020-02-11 Thread Mamed Shahmaliyev
Dear Ansible users,

recently i have been looking for some online service for on-hand ansible 
vault encrypt decrypt service and could not find anything. So i decided to 
write my own web interface: https://ansible-vault-tool.com/

Here you can decrypt or encrypt anything and no data is stored or logged. I 
hope it will be useful for ansible daily users.

-- 
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/503a1a12-34ab-4834-bb97-6a122d959fb1%40googlegroups.com.


[ansible-project] Re: how can i have my windows instances to use IP address instead of dns name?

2020-02-11 Thread Work-Hard
okay thank you

On Monday, February 10, 2020 at 6:26:03 PM UTC-8, Jordan Borean wrote:
>
> Just set the connection to use IPs as you would Linux it should just work. 
> Without seeing the error that you are receiving we can't help you anymore. 
> The most common reason why it doesn't is if you are using Kerberos auth. 
> This is because DNS is a very important part of Kerberos auth and using IPs 
> removes some of protection kerberos offers. It is still possible but I 
> wouldn't recommend it at all.
>

-- 
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/9d322bb0-2643-4756-af61-1d3d346f3fca%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Vladimir Botka
On Tue, 11 Feb 2020 14:59:04 -0800 (PST)
Anand Solomon  wrote:

> Instead of maintaining another template file. Can I embed the content in 
> the playbook itself ?

Sure you can. Put it into the "content". For example

- local_action:
copy dest=/scratch/tmp/revoke.sql
content="{% for line in query_result.msg|flatten %}{{ line }}{%
endfor %}"

But, why to get rid of the flexibility and modularity?

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/20200212000625.302d820b%40gmail.com.


pgpHxegko2PnH.pgp
Description: OpenPGP digital signature


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Instead of maintaining another template file. Can I embed the content in 
the playbook itself ?

On Tuesday, February 11, 2020 at 5:57:09 PM UTC-5, Anand Solomon wrote:
>
> Thank you so much Vlado. This works fine. 
>
> On Tuesday, February 11, 2020 at 5:40:05 PM UTC-5, Vladimir Botka wrote:
>>
>> On Tue, 11 Feb 2020 14:02:45 -0800 (PST) 
>> Anand Solomon  wrote: 
>>
>> > I need to get this 
>> > Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE 
>> from 
>> > TESTACC2; 
>>
>> To keep the element of the list in one line change the template. For 
>> example 
>>
>> $ cat revoke.sql.j2 
>> {% for line in query_result.msg|flatten %}{{ line }}{% endfor %} 
>>
>> 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/7916702f-dad6-4c61-a512-77586d7cc1b6%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Thank you so much Vlado. This works fine. 

On Tuesday, February 11, 2020 at 5:40:05 PM UTC-5, Vladimir Botka wrote:
>
> On Tue, 11 Feb 2020 14:02:45 -0800 (PST) 
> Anand Solomon > wrote: 
>
> > I need to get this 
> > Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE 
> from 
> > TESTACC2; 
>
> To keep the element of the list in one line change the template. For 
> example 
>
> $ cat revoke.sql.j2 
> {% for line in query_result.msg|flatten %}{{ line }}{% endfor %} 
>
> 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/507aba02-4db6-4a55-abba-a1b358cb6d22%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Vladimir Botka
On Tue, 11 Feb 2020 14:02:45 -0800 (PST)
Anand Solomon  wrote:

> I need to get this
> Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE from 
> TESTACC2;

To keep the element of the list in one line change the template. For example

$ cat revoke.sql.j2
{% for line in query_result.msg|flatten %}{{ line }}{% endfor %}

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/20200211233942.6d0dc015%40gmail.com.


pgpiGSHfNYEP8.pgp
Description: OpenPGP digital signature


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Vladimir Botka
On Tue, 11 Feb 2020 14:02:45 -0800 (PST)
Anand Solomon  wrote:

> "msg": {
> "ansible_facts": {
> "discovered_interpreter_python": "/usr/bin/python"
> },
> "changed": false,
> "failed": false,
> "msg": [
> [
> "Revoke EXECUTE on UTL_FILE from TESTACC1;"
> ],
> [
> "Revoke EXECUTE on UTL_FILE from TESTACC2;"
> ]
> ]
> }
> }
> 
> What I need to do is to generate another sql statement using this json 
> output. When I run your command, it gives me
> [u'Revoke EXECUTE on UTL_FILE from TESTACC1;'][u'Revoke EXECUTE on UTL_FILE 
> from TESTACC2;']
> 
> Is there a filter or something we can use to get a cleaner output ?
> 
> 
> On Tuesday, February 11, 2020 at 4:39:08 PM UTC-5, Hugo Gonzalez wrote:
> > Without knowing anything about how you got those values, it would be {{ 
> > query_result.msg | join(' ') }}

Try "template". For example

- local_action:
template src=revoke.sql.j2
dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql

with the template

$ cat revoke.sql.j2
{% for line in query_result.msg|flatten %}
{{ line }}
{% endfor %}

give

$ cat revoke.sql 
Revoke EXECUTE on UTL_FILE from TESTACC1;
Revoke EXECUTE on UTL_FILE from TESTACC2;

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/20200211232940.03b42943%40gmail.com.


pgpSh1YEXgAmU.pgp
Description: OpenPGP digital signature


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Thanks Hugo for helping me. Basically I am running a sql command that runs 
a sql query which gives the below results. (this is a debug out)

"msg": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"failed": false,
"msg": [
[
"Revoke EXECUTE on UTL_FILE from TESTACC1;"
],
[
"Revoke EXECUTE on UTL_FILE from TESTACC2;"
]
]
}
}

What I need to do is to generate another sql statement using this json 
output. When I run your command, it gives me
[u'Revoke EXECUTE on UTL_FILE from TESTACC1;'][u'Revoke EXECUTE on UTL_FILE 
from TESTACC2;']

Is there a filter or something we can use to get a cleaner output ?


On Tuesday, February 11, 2020 at 4:39:08 PM UTC-5, Hugo Gonzalez wrote:
>
> Without knowing anything about how you got those values, it would be {{ 
> query_result.msg | join(' ') }}
>
> Hugo G. 
>
>  
>
> If I do 
> - local_action:
> copy content={{query_result.msg}}
> dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql
>
> I am getting 
> [["Revoke EXECUTE on UTL_FILE from TESTACC1;"], ["Revoke EXECUTE on 
> UTL_FILE from TESTACC2;"]]
>
> I need to get this
> Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE from 
> TESTACC2;
>
> -- 
> 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/2a69d90d-3ea8-4615-8f63-ace11f83c622%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/e42fb674-799a-4f7d-bda2-b7c4905eb8d1%40googlegroups.com.


Re: [ansible-project] How to get clean output ?

2020-02-11 Thread Hugo Gonzalez
Without knowing anything about how you got those values, it would be {{ 
query_result.msg | join(' ') }}


Hugo G.





If I do
    - local_action:
        copy content={{query_result.msg}}
dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql

I am getting
[["Revoke EXECUTE on UTL_FILE from TESTACC1;"], ["Revoke EXECUTE on 
UTL_FILE from TESTACC2;"]]


I need to get this
Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE 
from TESTACC2;


--
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/2a69d90d-3ea8-4615-8f63-ace11f83c622%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/757a99a8-4b95-b3d2-d432-02335c18b7c7%40redhat.com.


Re: [ansible-project] When var1 == "yes" and var2 == "no"

2020-02-11 Thread Hugo Gonzalez



On 2/11/20 11:44 AM, Jesse Lyon wrote:

So,

I'm having fits with when conditionals matching strings
No matter what I do, it applies each conditional, the combination of 
the variables doesn't seem to count for ... anything.


what the heck am I doing wrong? additionally, is there a better way to 
do this?



Are you actually comparing the strings "yes" and "no" to the variables? 
If they're actual booleans, you will be better off by doing:


when: share_fim_managed and not share_azure_managed

when: not share_fim_managed and share_azure_managed

when: share_fim_managed and share_azure_managed


All nonempty strings are true, even if they contain the strings "false" 
or "true", you should be careful when comparing truth values. See here:



---
- hosts: localhost
  vars:
    truestringvar: "true"
    falsestringvar: "false"
    trueboolvar: true
    falseboolvar: false

  tasks:
    - debug:
    msg: Since booleans matter, this message is not shown.
  when: trueboolvar == 'true'
    - debug:
    msg: boolean values DO matter (this string is shown)
  when: trueboolvar
    - debug:
    msg: The string that says false is not false, this message will 
not be shown

  when: not falsestringvar





--
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/0ebabe47-8b80-60e3-3eb3-87d301627c0b%40redhat.com.


Re: [ansible-project] How do I include another playbook in current playbook?

2020-02-11 Thread Xinhuan Zheng
Hello Alicia,

This is great. I got the idea. Thanks for your help!

- Xinhuan

On Thursday, January 23, 2020 at 12:33:57 PM UTC-5, alicia wrote:
>
> You cannot import a playbook anywhere inside a play - importing a playbook 
> is a play of its own. 
>
> If you want to run the imported playbook first, try:
>
> - name: this play runs ‘another.yml' on the hosts it defines
>   import_playbook: another.yml
>
> - name: this play runs two roles on all hosts in the mywebservers group
>   hosts: mywebservers
>   gather_facts: yes
>
>   roles:
> - role: testrole1
>   tags: testrole1
> - role: testrole2
>   tags: othertag
>
> If you want to run the roles first, reverse the order of the two plays.
>
> You can also review the general documentation on importing and including 
> at https://docs.ansible.com/ansible/devel/user_guide/playbooks_reuse.html. 
> You may want to edit “another.yml” to make it a tasks file instead of a 
> playbook for greater flexibility.
>
> Hope this helps,
> Alicia
>
> On Jan 22, 2020, at 3:24 PM, Xinhuan Zheng  > wrote:
>
>
>   Take a look again at the example in 
>>
>> https://docs.ansible.com/ansible/latest/modules/import_playbook_module.html. 
>>
>> To me it does not know where 
>>
>>
>>   roles: 
>> - role: testrole1 
>>   tags: testrole1 
>>
>> belongs. Should it be 
>>
>> - hosts: mywebservers 
>>   gather_facts: yes 
>>
>>   roles: 
>> - role: testrole1 
>>   tags: testrole1 
>>
>> #- import_playbook: another.yml 
>>
>> i.e. those roles are related to mywebservers? Or are they related to 
>> all hosts as defined in another.yml? 
>>
>>
>>
> testrole1 belongs to mywebservers. It isn't related to all hosts as 
> defined in another.yml file. However, another.yml file needs to be called 
> first. I tried using pre_tasks with import_playbook. It doesn't work 
> either. I also tried using include, still not working. Since another.yml 
> file contains a list of roles, it is supposed to be import_playbook, but 
> I'm not sure how to make import_playbook working in current_playbook.yml 
> file.
>
> Thanks again,
>
> - Xinhuan
>
> -- 
> 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/ea2a316c-0d8e-4641-9e94-d10e708b3ea5%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/0c1fa28a-b8a6-4df2-9d20-1e0efd99789c%40googlegroups.com.


[ansible-project] How to get clean output ?

2020-02-11 Thread Anand Solomon
Hi,
How will I get only the sql statement from the json output ? I am 
registering this as " register: query_result"

Here is my json output



"msg": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"failed": false,
"msg": [
[
"Revoke EXECUTE on UTL_FILE from TESTACC1;"
],
[
"Revoke EXECUTE on UTL_FILE from TESTACC2;"
]
]
}
}



If I do 
- local_action:
copy content={{query_result.msg}}
dest=/home/ansible/Playbooks/{{sname}}/sql/revoke.sql

I am getting 
[["Revoke EXECUTE on UTL_FILE from TESTACC1;"], ["Revoke EXECUTE on 
UTL_FILE from TESTACC2;"]]

I need to get this
Revoke EXECUTE on UTL_FILE from TESTACC1; Revoke EXECUTE on UTL_FILE from 
TESTACC2;

-- 
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/2a69d90d-3ea8-4615-8f63-ace11f83c622%40googlegroups.com.


[ansible-project] Re: How to fix warning message conditional statements should not include jinja2 templating delimiters

2020-02-11 Thread Jordan Borean
- debug:
msg: Hi
  when:
  - entrycurrdb.stdout.find(hostvars['localhost']['BASEPATH_FINAL'] ~ '/' ~ 
vars[(item | splitext)[1].split('.')[1] | default('exe')] ~ '/' ~ item | 
basename) == -1
  - actualfile.stat.exists | bool

A few comments though

   - This is an extremely complex and weird conditional that will be hard 
   for anything to read and understand what is happening. Consider simplifying 
   it as much as you can or using set_fact beforehand to build the path to 
   find components so you can better document it.
   - Split every and condition only a new entry to reduce the line length, 
   each entry is just and'd together
   - The '~' is a jinja2 string concatenation operator that works similar 
   to '+' but it converts both sides to a string before adding it together 
   making it better for what you want
   - The reason why the warning still showed is because you still have 
   jinja2 blocks, technically they are required in your example because you 
   have it in a string but what you should be doing is not enclse the var in a 
   string and concat it together

I haven't tested this but it "should" work.

-- 
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/f1aae5f8-b18e-4f6b-b770-b3a741d8cb8d%40googlegroups.com.


Re: [ansible-project] When var1 == "yes" and var2 == "no"

2020-02-11 Thread Jesse Lyon
Perfect!

I didn't realize the indentation had to be outside the module parameter, 
the example I was using was poorly written it seems.

I appreciate the help Stefan!

--
Jess

On Tuesday, February 11, 2020 at 12:51:14 PM UTC-5, Stefan Hornburg (Racke) 
wrote:
>
> On 2/11/20 6:44 PM, Jesse Lyon wrote: 
> > So, 
> > 
> > I'm having fits with when conditionals matching strings 
> > No matter what I do, it applies each conditional, the combination of the 
> variables doesn't seem to count for ... anything. 
> > 
> > what the heck am I doing wrong? additionally, is there a better way to 
> do this? 
>
> Hello Jessie, 
>
> it looks like your indentation is wrong. when is a task parameter and not 
> a module parameter: 
>
> - name: ... 
>   win_domain_group: 
> domain_server:"{{ h_domain_server }}" 
> ... 
>   when: share_fim_managed =="yes"andshare_azure_managed =="no" 
>
> Regards 
>  Racke 
>
> > 
> > | 
> >   -name:H -SetFIM Flag-RW 
> > win_domain_group: 
> >   when:share_fim_managed =="yes"andshare_azure_managed =="no" 
> >   domain_server:"{{ h_domain_server }}" 
> >   domain_username:"{{ h_domain_username }}" 
> >   domain_password:"{{ h_domain_password }}" 
> >   scope:global 
> >   name:"{{ h_g_prefix }}{{ g_name }}{{suffix_RW}}" 
> >   attributes: 
> > NCHIDMMGI:FIM Managed-'{{ dateformat }}' 
> >   
> >   -name:H -SetAzureFlag-RW 
> > win_domain_group: 
> >   domain_server:"{{ h_domain_server }}" 
> >   domain_username:"{{ h_domain_username }}" 
> >   domain_password:"{{ h_domain_password }}" 
> >   scope:global 
> >   name:"{{ h_g_prefix }}{{ g_name }}{{suffix_RW}}" 
> >   attributes: 
> > NCHIDMMGI:AzureManaged-'{{ dateformat }}' 
> >   when:share_fim_managed =="no"andshare_azure_managed =="yes" 
> >   -name:R -SetFIM/AzureFlag-RW 
> > win_domain_group: 
> >   domain_server:"{{ r_domain_server }}" 
> >   domain_username:"{{ r_domain_username }}" 
> >   domain_password:"{{ r_domain_password }}" 
> >   scope:global 
> >   protect:yes 
> >   name:"{{ r_g_prefix }}{{ g_name }}{{suffix_RW}}" 
> >   attributes: 
> >NCHIDMMGI:FIM /AzureManaged-'{{ dateformat }}' 
> >   when:share_fim_managed =="yes"andshare_azure_managed =="yes" 
> > 
> > 
> > 
> > 
> > ## from the include file 
> > 
> > 
> > share_fim_managed:"no" 
> > share_azure_managed:"yes" 
> > | 
> > 
> > -- 
> > 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/220f3ee5-5c28-42ee-befa-429ffa43b249%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/220f3ee5-5c28-42ee-befa-429ffa43b249%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/c3416b83-33de-44bc-a444-5fda1fe85184%40googlegroups.com.


Re: [ansible-project] When var1 == "yes" and var2 == "no"

2020-02-11 Thread Stefan Hornburg (Racke)
On 2/11/20 6:44 PM, Jesse Lyon wrote:
> So,
> 
> I'm having fits with when conditionals matching strings
> No matter what I do, it applies each conditional, the combination of the 
> variables doesn't seem to count for ... anything.
> 
> what the heck am I doing wrong? additionally, is there a better way to do 
> this?

Hello Jessie,

it looks like your indentation is wrong. when is a task parameter and not a 
module parameter:

- name: ...
  win_domain_group:
domain_server:"{{ h_domain_server }}"
...
  when: share_fim_managed =="yes"andshare_azure_managed =="no"

Regards
 Racke

> 
> |
>   -name:H -SetFIM Flag-RW
>     win_domain_group:
>       when:share_fim_managed =="yes"andshare_azure_managed =="no"
>       domain_server:"{{ h_domain_server }}"
>       domain_username:"{{ h_domain_username }}"
>       domain_password:"{{ h_domain_password }}"
>       scope:global
>       name:"{{ h_g_prefix }}{{ g_name }}{{suffix_RW}}"
>       attributes:
>         NCHIDMMGI:FIM Managed-'{{ dateformat }}'
>  
>   -name:H -SetAzureFlag-RW
>     win_domain_group:
>       domain_server:"{{ h_domain_server }}"
>       domain_username:"{{ h_domain_username }}"
>       domain_password:"{{ h_domain_password }}"
>       scope:global
>       name:"{{ h_g_prefix }}{{ g_name }}{{suffix_RW}}"
>       attributes:
>         NCHIDMMGI:AzureManaged-'{{ dateformat }}'
>       when:share_fim_managed =="no"andshare_azure_managed =="yes"
>   -name:R -SetFIM/AzureFlag-RW
>     win_domain_group:
>       domain_server:"{{ r_domain_server }}"
>       domain_username:"{{ r_domain_username }}"
>       domain_password:"{{ r_domain_password }}"
>       scope:global
>       protect:yes
>       name:"{{ r_g_prefix }}{{ g_name }}{{suffix_RW}}"
>       attributes:
>        NCHIDMMGI:FIM /AzureManaged-'{{ dateformat }}'
>       when:share_fim_managed =="yes"andshare_azure_managed =="yes"
> 
> 
> 
> 
> ## from the include file
> 
> 
> share_fim_managed:"no"
> share_azure_managed:"yes"
> |
> 
> -- 
> 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/220f3ee5-5c28-42ee-befa-429ffa43b249%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/0e55e946-a68f-59f8-da3b-d42d39f9bd2d%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Re: win_domain_group_membership

2020-02-11 Thread Jesse Lyon
I fixed it from the above error, PEBKAC.
Updated the PR :)

On Monday, February 10, 2020 at 4:28:05 PM UTC-5, Jesse Lyon wrote:
>
> The full traceback is:
> Could not add member(s) to one or more ADGroup.
> At line:82 char:9
> + Add-ADPrincipalGroupMembership -Identity $group_member -Membe 
> ...
> + ~
> + CategoryInfo  : OperationStopped: (Microsoft.Activ...ement.
> ADGroup[]:ADGroup[]) [Add-ADPrincipalGroupMembership], ADException
> + FullyQualifiedErrorId : 1,Microsoft.ActiveDirectory.Management.
> Commands.AddADPrincipalGroupMembership
>
>
> ScriptStackTrace:
> at , : line 82
>
>
> Microsoft.ActiveDirectory.Management.ADException: Could not add member(s) 
> to one or more ADGroup.
>at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError
> (ErrorRecord errorRecord)
> fatal: [ansible01.domain.DEV]: FAILED! => {
> "changed": false,
> "msg": "Unhandled exception while executing module: Could not add 
> member(s) to one or more ADGroup."
> }
>
>
>
>
> On Monday, February 10, 2020 at 4:22:50 PM UTC-5, Jesse Lyon wrote:
>>
>> My bad on linking to the wrong issue :)
>>
>> I've pulled it down and am giving it a shot now, will have results and 
>> comment on the PR if successful... so far I'm fighting the woes of a 
>> stripped down dev domain.
>>
>> Thanks again Jordan.
>>
>> On Monday, February 10, 2020 at 2:03:12 PM UTC-5, Jordan Borean wrote:
>>>
>>> Looks like I jumped the gun with closing that issue, the backported 
>>> issue referenced is for a separate problem. The actual cross domain support 
>>> of groups is still not supported in the module. There is a PR which you can 
>>> try out https://github.com/ansible/ansible/pull/65138 and comment on if 
>>> it solves your issue.
>>>
>>

-- 
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/dc635419-c24a-4e9f-9ffc-247a537f7fb9%40googlegroups.com.


[ansible-project] When var1 == "yes" and var2 == "no"

2020-02-11 Thread Jesse Lyon
So,

I'm having fits with when conditionals matching strings
No matter what I do, it applies each conditional, the combination of the 
variables doesn't seem to count for ... anything.

what the heck am I doing wrong? additionally, is there a better way to do 
this?

  - name: H - Set FIM Flag - RW
win_domain_group:
  when: share_fim_managed == "yes" and share_azure_managed == "no"
  domain_server: "{{ h_domain_server }}"
  domain_username: "{{ h_domain_username }}"
  domain_password: "{{ h_domain_password }}"
  scope: global
  name: "{{ h_g_prefix }}{{ g_name }}{{suffix_RW}}"
  attributes:
NCHIDMMGI: FIM Managed - '{{ dateformat }}'
  
  - name: H - Set Azure Flag - RW
win_domain_group:
  domain_server: "{{ h_domain_server }}"
  domain_username: "{{ h_domain_username }}"
  domain_password: "{{ h_domain_password }}"
  scope: global
  name: "{{ h_g_prefix }}{{ g_name }}{{suffix_RW}}"
  attributes:
NCHIDMMGI: Azure Managed - '{{ dateformat }}'
  when: share_fim_managed == "no" and share_azure_managed == "yes"
  - name: R - Set FIM/Azure Flag - RW
win_domain_group:
  domain_server: "{{ r_domain_server }}"
  domain_username: "{{ r_domain_username }}"
  domain_password: "{{ r_domain_password }}"
  scope: global
  protect: yes
  name: "{{ r_g_prefix }}{{ g_name }}{{suffix_RW}}"
  attributes:
   NCHIDMMGI: FIM / Azure Managed - '{{ dateformat }}'
  when: share_fim_managed == "yes" and share_azure_managed == "yes"




## from the include file


share_fim_managed: "no"
share_azure_managed: "yes"

-- 
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/220f3ee5-5c28-42ee-befa-429ffa43b249%40googlegroups.com.


Re: [ansible-project] How to split a json key containing a colon into 2 keys

2020-02-11 Thread jean-christophe manciot
I'm impressed. It works perfectly. Only the first key is split as expected..

On Friday, February 7, 2020 at 7:12:40 PM UTC+1, Vladimir Botka wrote:
>
> On Fri, 7 Feb 2020 08:14:56 -0800 (PST) 
> jean-christophe manciot > wrote: 
>
> > I receive some json data which *sometimes* start with the first key 
> within 
> > "json_data" variable containing a ':', such as: 
> > "json_data": { 
> > "key1:key2": { 
> > "key3": [ 
> > "value31", 
> > "value32", 
> > "..." 
> > ] 
> > } 
> > } 
> > 
> > The goal is to split "key1:key2" into 2 keys so that we end up with: 
> > "json_data": { 
> > "key1": { 
> > "key2": { 
> > "key3": [ 
> > "value31", 
> > "value32", 
> > "..." 
> > ] 
> > } 
> > } 
> > } 
>
>
> Try this 
>
>- set_fact: 
> json_data1: "{{ json_data1|default({})|combine(my_key) }}" 
>   vars: 
> my_keys: "{{ item.key.split(':') }}" 
> my_keys_length: "{{ my_keys|length == 1 }}" 
> my_key: "{{ my_keys_length| 
> ternary({my_keys[0]: item.value}, 
> {my_keys[0]: 
> {my_keys[1:]|join(':')|default('NA'): 
>  item.value}}) }}" 
>   loop: "{{ json_data|dict2items }}" 
>
> 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/1f82855d-3090-4502-87f1-d3a6aec28aa6%40googlegroups.com.


[ansible-project] use binascii.unhexlify() in Jinja2 template

2020-02-11 Thread Michael Ströder
HI!

I'm using stat task to let ansible calculate the SHA-512 checksum of a
file on the managed node [1] which returns hex-encoded hash values.

Now I have to convert the checksum to bytes prior to base64-encoding
this byte string.

In Python code I would use the function binascii.unhexlify(). But how to
do this in a Jinja2 template?

(I'm doing this to implement Subresource Integrity [3].)

Thanks in advance.

Ciao, Michael.

[1] https://docs.ansible.com/ansible/latest/modules/stat_module.html

[2] https://docs.python.org/3/library/binascii.html#binascii.unhexlify

[3]
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity

-- 
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/0a9b1792-4935-7872-f0c9-4ff9e4fa2bba%40stroeder.com.


[ansible-project] How to fix warning message conditional statements should not include jinja2 templating delimiters

2020-02-11 Thread Shifa Shaikh
How do I make changes to the below complex when condition without breaking 
the code in order to address the warning. 

 - debug: msg: "Hi"
 when: entrycurrdb.stdout.find("{{ 
hostvars['localhost']['BASEPATH_FINAL'] }}/{{ vars[(item | 
splitext)[1].split('.')[1] | default('exe')] }}/{{ item | basename }}") == -
1 and actualfile.stat.exists == True

Getting warning

Output:


TASK [debug] 
> ***
> [WARNING]: conditional statements should not include jinja2 templating
> delimiters such as {{ }} or {% %}. Found: entrycurrdb.stdout.find("{{
> hostvars['localhost']['BASEPATH_FINAL'] }}/{{ vars[(item |
> splitext)[1].split('.')[1] | default('exe')] }}/{{ item | basename }}") == 
> -1
> and actualfile.stat.exists == True
> changed: [10.0.0.16]


Kindly suggests. 

-- 
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/40f2ed22-985b-4fe3-8fd1-b509f497551f%40googlegroups.com.


[ansible-project] How to fix warning message conditional statements should not include jinja2 templating delimiters

2020-02-11 Thread Shifa Shaikh
How do I make changes to the below complex when condition without breaking 
the code in order to address the warning. 

 - debug: msg: "Hi"
 when: entrycurrdb.stdout.find("{{ 
hostvars['localhost']['BASEPATH_FINAL'] }}/{{ vars[(item | 
splitext)[1].split('.')[1] | default('exe')] }}/{{ item | basename }}") == -
1 and actualfile.stat.exists == True

Getting warning

Output:


TASK [shell] 
> ***
> [WARNING]: conditional statements should not include jinja2 templating
> delimiters such as {{ }} or {% %}. Found: entrycurrdb.stdout.find("{{
> hostvars['localhost']['BASEPATH_FINAL'] }}/{{ vars[(item |
> splitext)[1].split('.')[1] | default('exe')] }}/{{ item | basename }}") == 
> -1
> and actualfile.stat.exists == True
> changed: [10.0.0.16]


Kindly suggests. 

-- 
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/344ea14e-1b5a-4e37-874b-9de23fc4e90a%40googlegroups.com.


[ansible-project] Re: simple problem has me stumped

2020-02-11 Thread misterT1958
Ah,

now I see what you mean - got it working!  Thanks so much for the hand!

kind regards,
T

On Monday, February 10, 2020 at 4:33:14 PM UTC-5, misterT1958 wrote:
>
> I have a simple scenario that fails, but I can't figure out why.  Here's 
> the command line invocation and the result:
>
> [root@cluster-mgmt tasks]# ansible-playbook -i ./hosts main.yml
>
> PLAY [CLUSTERS team downtime orchestration play] 
> 
>
> TASK [Gathering Facts] 
> **
> ok: [localhost]
>
> TASK [set nagios downtime] 
> **
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with 
> an undefined variable. The error was: 'myTestVar' is undefined\n\nThe error 
> appears to have been in 
> '/autofs/nccs-svm1_home1/tw58/SANDBOX/ANSIBLE_VARDIR/testVar/tasks/main.yml': 
> line 9, column 5, but may\nbe elsewhere in the file depending on the exact 
> syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n  - name: 
> set nagios downtime\n^ here\n"}
>  [WARNING]: Could not create retry file 
> '/autofs/nccs-svm1_home1/tw58/SANDBOX/ANSIBLE_VARDIR/testVar/tasks/main.retry'.
>   
>[Errno 13] Permission denied:
>
> u'/autofs/nccs-svm1_home1/tw58/SANDBOX/ANSIBLE_VARDIR/testVar/tasks/main.retry'
>
>
> PLAY RECAP 
> **
> localhost  : ok=1changed=0unreachable=0failed=1
>
> The playbook is simple:
>
> ---
> # tasks file for testVar
>
> - hosts: localhost
>   name: CLUSTERS team downtime orchestration play
>   gather_facts: true
>
>   tasks:
>   - name: set nagios downtime
> debug:
>   msg: "the value of the variable {{ myTestVar }}"
>
> and the variable definition file is even more simple:
>
> [root@cluster-mgmt vars]# more main.yml
> ---
> # vars file for testVar
> myTestVar: 58
>
> This is my directory tree:
>
> [root@cluster-mgmt testVar]# tree
> .
> ├── ansible.cfg
> ├── defaults
> │   └── main.yml
> ├── files
> ├── handlers
> │   └── main.yml
> ├── hosts
> ├── meta
> │   └── main.yml
> ├── README.md
> ├── tasks
> │   ├── ansible.cfg -> ../ansible.cfg
> │   ├── hosts -> ../hosts
> │   └── main.yml
> ├── templates
> ├── tests
> │   ├── inventory
> │   └── test.yml
> └── vars
> └── main.yml
>
> Been staring at this all day, trying different things, always get the 
> "undefined variable"!!
>
> Does anybody out there see the problem?
>
> Thanks
> T
>

-- 
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/b4e3325a-a426-4a04-9b62-5738b36b5bb9%40googlegroups.com.


Re: [ansible-project] Jinja2 template loop with JSON

2020-02-11 Thread Juergen Hofer


Am Dienstag, 11. Februar 2020 13:23:16 UTC+1 schrieb Stefan Hornburg 
(Racke):
>
>
> Hello Juergen, 
>
> this should do the trick: 
>
> {% for item in host.INT_LIST %} 
>
> I suggest to pick a different loop variable name as "item" is the standard 
> one 
> in Jinja. 
>
> Regards 
>  Racke 
>

Hello Racke,

this was the missing part. :)

Thank you so much!
Regards from Switzerland
Juergen

 

-- 
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/ccc30979-85e7-4346-9317-f02d9fe74f1f%40googlegroups.com.


Re: [ansible-project] parted - azure managed disks - unrecognized disk label

2020-02-11 Thread 'deewon' via Ansible Project
I got to the bottom of this eventually :)

The task was running on the controller which didn't have a /dev/sdc device 
:)

Simply delegating the task to the remote node fixed the problem

Thanks!


On Tuesday, February 11, 2020 at 10:41:44 AM UTC, deewon wrote:
>
> Thanks Hugo!
>
> I gave this a go with the label explicitly specified and it returned the 
> same error i.e.
>
> - name: Partition Disk
>   parted:
> device: /dev/sdc
> number: 1
> state: present
> label: msdos
>
>   
>
> TASK [role_azure_disk : Partition Azure Disk] 
> ***
> task path: /etc/ansible/roles/role_azure_disk/tasks/main.yml:19
> fatal: [dbbox8]: FAILED! => {"changed": false, "err": "Error: Could not 
> stat device /dev/sdc - No such file or directory.\n", "msg": "Error while 
> getting device information with parted script: '/sbin/parted -s -m /dev/sdc 
> -- unit 'KiB' print'", "out": "", "rc": 1}
>
>
> I suppose the issue is more related to the disk profile as opposed to the 
> parted module in itself?  The disk itself was created as recommended by 
> azure (
> https://docs.microsoft.com/en-us/azure/virtual-machines/linux/add-disk) 
>
> Regards
>
> On Monday, February 10, 2020 at 7:01:17 PM UTC, Hugo Gonzalez wrote:
>>
>>
>> On 2/10/20 3:49 AM, 'deewon' via Ansible Project wrote:
>>
>> Hi all, 
>>
>> I'm pretty certain someone has figured this out so any hints will be 
>> appreciated
>>
>> I've attached an  azure managed disk to a linux vm  but noticed it 
>> doesn't have any disk label  i.e.
>>
>>
>> The disk label is the partition table, and will not be recognized for an 
>> unpartitioned disk. There is a parameter in the module called "label" with 
>> a default of "msdos" as the table format.
>>
>>
>> https://docs.ansible.com/ansible/latest/modules/parted_module.html#parameter-label
>>
>> So I guess you can pass it along your partition definitions. Just make 
>> sure it works idempotently, I haven't tested it.
>>
>> Hugo G.
>>
>>
>>
>>
>>
>> Consequently, the ansible parted module returns the below error when 
>> attempting to create a partition
>>
>> TASK [role_azure_disk : Partition Azure Disk] 
>> ***
>> task path: /etc/ansible/roles/role_azure_disk/tasks/main.yml:7
>> fatal: [labserver]: FAILED! => {"changed": false, "err": "Error: Could 
>> not stat device /dev/sdc - No such file or directory.\n", "msg": "Error 
>> while getting device information with parted script: '/sbin/parted -s -m 
>> /dev/sdc -- unit 'KiB' print'", "out": "", "rc": 1}
>>
>> To achieve idempotence when re-running playbooks , I'm trying to avoid 
>> using fdisk passed to the shell module  i.e. (echo n; echo p; echo 1; echo 
>> ; echo ; echo w) | sudo fdisk /dev/sdc
>>
>> Will appreciate any ideas on how to get around this
>>
>> Thanks
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/49c9a80b-1302-4463-a6ee-0e1a2e049e8b%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/8b052201-0145-48cd-b48c-feb6a893300c%40googlegroups.com.


Re: [ansible-project] Jinja2 template loop with JSON

2020-02-11 Thread Stefan Hornburg (Racke)
On 2/11/20 1:14 PM, Juergen Hofer wrote:
> Hello all,
> 
> I am a Network Engineer and Ansible is relative new for me.
> 
> At the moment I am trying to build a template with "JSON" as source. See 
> below.
> 
> The template should do the follwing (hopefully you get the idea).
> I am struggling, how can i get the items in the list "INT_LIST" ?
> Can someone point my to a good sample or documentation.
> 
> TIA
> Juergen

Hello Juergen,

this should do the trick:

{% for item in host.INT_LIST %}

I suggest to pick a different loop variable name as "item" is the standard one
in Jinja.

Regards
 Racke

>
> 
> --
> Jinja Template
> --
> {% for host in host_with_properties %}
> 
> hostname  {{ host.HOST_NAME }}
> 
> {% for item in INT_LIST %}
> 
> interface {{ item.int_phy01 }}
> 
> {% endfor %}
> {% endfor %}
> 
> --
> 
> Source:
> --
> {
> "all_hosts_unique":
> [
>     "host01",
>     "host02"
> ],
> 
> "host_with_properties":
> [
>     {
>         "HOST_NAME": "host01",
>         "INT_LIST": [
>             {
>                 "beid": "100",
>                 "dot1qid": "10",
>                 
>             },
>             {
>                 "beid": "100",
>                 "dot1qid": "11",
>                 "hsrp_ip": "10.10.20.1",
>                 "int_be_desc": "test",
>                 "int_phy01": "TenGigE0/0/0/3",
>                 "int_phy01_desc": "test02",
>                 "int_phy02": "TenGigE0/0/0/4",
>                 "int_phy02_desc": "test03",
>                 "int_sub_desc": "test",
>                 "int_sub_ip": "10.10.20.11",
>                 "int_sub_net": "255.255.255.0",
>                 "int_sub_vrf": "mgt-net"
>             },
>             {
>                 "beid": "100",
>                 "dot1qid": "12",
>                 "hsrp_ip": "10.10.30.1",
>                 "int_be_desc": "test",
>                 "int_phy01": "TenGigE0/0/0/5",
>                 "int_phy01_desc": "test03",
>                 "int_phy02": "TenGigE0/0/0/6",
>                 "int_phy02_desc": "test04",
>                 "int_sub_desc": "test",
>                 "int_sub_ip": "10.10.30.12",
>                 "int_sub_net": "255.255.255.0",
>                 "int_sub_vrf": "mgt-net"
>             }
>         ]
>     },
>     {
>         "HOST_NAME": "host02",
>         "INT_LIST": [
>             {
>                 "beid": "111",
>                 "dot1qid": "10",
>                 "hsrp_ip": "10.10.10.1",
>                 "int_be_desc": "test",
>                 "int_phy01": "TenGigE0/0/0/7",
>                 "int_phy01_desc": "test01",
>                 "int_phy02": "TenGigE0/0/0/2",
>                 "int_phy02_desc": "test02",
>                 "int_sub_desc": "test",
>                 "int_sub_ip": "10.10.10.10",
>                 "int_sub_net": "255.255.255.0",
>                 "int_sub_vrf": "mgt-net"
>             },
>             {
>                 "beid": "222",
>                 "dot1qid": "11",
>                 "hsrp_ip": "10.10.20.1",
>                 "int_be_desc": "test",
>                 "int_phy01": "TenGigE0/0/0/8",
>                 "int_phy01_desc": "test02",
>                 "int_phy02": "TenGigE0/0/0/4",
>                 "int_phy02_desc": "test03",
>                 "int_sub_desc": "test",
>                 "int_sub_ip": "10.10.20.11",
>                 "int_sub_net": "255.255.255.0",
>                 "int_sub_vrf": "bla-net"
>             },
>             {
>                 "beid": "333",
>                 "dot1qid": "12",
>                 "hsrp_ip": "10.10.30.1",
>                 "int_be_desc": "test",
>                 "int_phy01": "TenGigE0/0/0/9",
>                 "int_phy01_desc": "test03",
>                 "int_phy02": "TenGigE0/0/0/6",
>                 "int_phy02_desc": "test04",
>                 "int_sub_desc": "test",
>                 "int_sub_ip": "10.10.30.12",
>                 "int_sub_net": "255.255.255.0",
>                 "int_sub_vrf": "gu-net"
>             }
>         ]
>     }
> ]
> }
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/98d06d13-edb2-44fd-95c4-bf70eeef18fa%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 

[ansible-project] Jinja2 template loop with JSON

2020-02-11 Thread Juergen Hofer
Hello all,

I am a Network Engineer and Ansible is relative new for me.

At the moment I am trying to build a template with "JSON" as source. See 
below.

The template should do the follwing (hopefully you get the idea).
I am struggling, how can i get the items in the list "INT_LIST" ?
Can someone point my to a good sample or documentation.

TIA
Juergen

--
Jinja Template
--
{% for host in host_with_properties %}

hostname  {{ host.HOST_NAME }}

{% for item in INT_LIST %}

interface {{ item.int_phy01 }}

{% endfor %}
{% endfor %}

--

Source:
--
{
"all_hosts_unique":
[
"host01",
"host02"
],

"host_with_properties":
[
{
"HOST_NAME": "host01",
"INT_LIST": [
{
"beid": "100",
"dot1qid": "10",

},
{
"beid": "100",
"dot1qid": "11",
"hsrp_ip": "10.10.20.1",
"int_be_desc": "test",
"int_phy01": "TenGigE0/0/0/3",
"int_phy01_desc": "test02",
"int_phy02": "TenGigE0/0/0/4",
"int_phy02_desc": "test03",
"int_sub_desc": "test",
"int_sub_ip": "10.10.20.11",
"int_sub_net": "255.255.255.0",
"int_sub_vrf": "mgt-net"
},
{
"beid": "100",
"dot1qid": "12",
"hsrp_ip": "10.10.30.1",
"int_be_desc": "test",
"int_phy01": "TenGigE0/0/0/5",
"int_phy01_desc": "test03",
"int_phy02": "TenGigE0/0/0/6",
"int_phy02_desc": "test04",
"int_sub_desc": "test",
"int_sub_ip": "10.10.30.12",
"int_sub_net": "255.255.255.0",
"int_sub_vrf": "mgt-net"
}
]
},
{
"HOST_NAME": "host02",
"INT_LIST": [
{
"beid": "111",
"dot1qid": "10",
"hsrp_ip": "10.10.10.1",
"int_be_desc": "test",
"int_phy01": "TenGigE0/0/0/7",
"int_phy01_desc": "test01",
"int_phy02": "TenGigE0/0/0/2",
"int_phy02_desc": "test02",
"int_sub_desc": "test",
"int_sub_ip": "10.10.10.10",
"int_sub_net": "255.255.255.0",
"int_sub_vrf": "mgt-net"
},
{
"beid": "222",
"dot1qid": "11",
"hsrp_ip": "10.10.20.1",
"int_be_desc": "test",
"int_phy01": "TenGigE0/0/0/8",
"int_phy01_desc": "test02",
"int_phy02": "TenGigE0/0/0/4",
"int_phy02_desc": "test03",
"int_sub_desc": "test",
"int_sub_ip": "10.10.20.11",
"int_sub_net": "255.255.255.0",
"int_sub_vrf": "bla-net"
},
{
"beid": "333",
"dot1qid": "12",
"hsrp_ip": "10.10.30.1",
"int_be_desc": "test",
"int_phy01": "TenGigE0/0/0/9",
"int_phy01_desc": "test03",
"int_phy02": "TenGigE0/0/0/6",
"int_phy02_desc": "test04",
"int_sub_desc": "test",
"int_sub_ip": "10.10.30.12",
"int_sub_net": "255.255.255.0",
"int_sub_vrf": "gu-net"
}
]
}
]
}

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


Re: [ansible-project] How to ron SQL stored Procedures with Ansible

2020-02-11 Thread Kai Stian Olstad
On Wed, Feb 05, 2020 at 11:01:17AM -0600, Jeff Knights wrote:
> How do I get ansible to run a folder full of SQL stored procedures on a
> remote sql server?
> 
> any help would be appreciated.

You could use find module to find all the file and then run them with
command/shell module if there is no other module to execute them.

-- 
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/2020023555.2vbsb7or4zdx2qlv%40olstad.com.


Re: [ansible-project] Ansible expect module with Oracle SBC

2020-02-11 Thread Kai Stian Olstad
On Wed, Feb 05, 2020 at 01:05:57AM -0800, Gerhard Van Der Wath wrote:
> Hi.

Hi, if you had posted a plain text mail instead of HTML you would have gotten a
replay a lot sooner.
As you can see bellow you formatting is hard to read.


> tasks:
> 
> - name: Get CPU load
> expect:
> command: ssh admin@#
> responses:
> 'password: ':
> - ###
> '#':
> - sh platform cpu-load
> 
> 
> 
> Error:
> 
> fatal: [##]: FAILED! => { "changed": false, "invocation": { 
> "module_args": { "chdir": null, "command": "ssh admin@##", "creates": 
> null, "echo": false, "removes": null, "responses": { "#": [ "sh platform 
> cpu-load" ], "password: ": [ "##" ] }, "timeout": 30 } }, "msg": "No 
> remaining responses for '#', output was ' sh platform 
> cpu-load\r\nTimestamp: 10:49:41 Wed 2020-02-05\r\nTotal load : 4%\r\nCPU 00 
> load : 5%\r\nCPU 01 load : 3%\r\nCPU 02 load : 5%\r\nCPU 03 load : 
> 5%\r\nVOXBDLHA1#'" } 

As the msg says expect has gotten a prompt # put have no more command to give.
Remember that expect is you substitute for a human typing inn commands, so you
need to provide all command from start, ssh in you case, to the exit of the ssh 
command.

So you need to add an element to the item "#" in your responses to exit the 
command.

-- 
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/2020023332.l6sb4feyxlgdtduo%40olstad.com.


[ansible-project] Automating LDAP integration of artifactory using ansible

2020-02-11 Thread Vishal Bobade
Hi, 

could some one help me in understanding if the below yaml code can be used 
in ansible-playbook to achieve the automation of LDAP integration.

security:   #Security configuration (LDAP, SAML, Password Policy, ...)
  ldapSettings:   #LDAP server(s) settings
ldap1:   #The unique ID of the LDAP setting
  emailAttribute: email1   #An attribute that can be used to map a 
user's email to a user created automatically by Artifactory
  ldapPoisoningProtection: true   #When set to true (recommended), 
Artifactory will protect against LDAP poisoning by filtering out users 
exposed to vulnerability
  ldapUrl: ldap://myserver:myport/dc=sampledomain,dc=com   #Location of 
the LDAP server in the following format: 
ldap://myserver:myport/dc=sampledomain,dc=com. The URL should include the 
base DN used to search for and/or authenticate users
  search:
managerDn: manager1   #The full DN of a user with permissions that 
allow querying the LDAP server. When working with LDAP Groups, the user 
should have permissions for any extra group attributes such as memberOf
managerPassword: managerpass1   #The password of the user binding 
to the LDAP server when using "search" authentication
searchBase: searchbase1   #The Context name in which to search 
relative to the base DN in the LDAP URL. Multiple search bases may be 
specified separated by a pipe ( | ). This is parameter is optional
searchFilter: searchfilter1   #A filter expression used to search 
for the user DN that is used in LDAP authentication. Possible examples are: 
uid={0}) - this would search for a username match on the uid attribute. 
Authentication using LDAP is performed from the DN found if successful
searchSubTree: true   #When set, enables deep search through the 
sub-tree of the LDAP URL + Search Base
  userDnPattern: userppatt1  #A DN pattern used to log users directly 
in to the LDAP database. This pattern is used to create a DN string for 
"direct" user authentication, and is relative to the base DN in the LDAP 
URL. For example: uid={0},ou=People
  allowUserToAccessProfile: false   #When set, users created after 
logging in using LDAP will be able to access their profile page in 
Artifactory
  autoCreateUser: true   #When set, Artifactory will automatically 
create new users for those who have logged in using LDAP, and assign them 
to the default groups
  enabled: true   #When set, these settings are enabled
Samp

-- 
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/f9d8e4a5-cb48-4351-9154-ad9329ab7dd0%40googlegroups.com.


Re: [ansible-project] parted - azure managed disks - unrecognized disk label

2020-02-11 Thread 'deewon' via Ansible Project
Thanks Hugo!

I gave this a go with the label explicitly specified and it returned the 
same error i.e.

- name: Partition Disk
  parted:
device: /dev/sdc
number: 1
state: present
label: msdos

  

TASK [role_azure_disk : Partition Azure Disk] 
***
task path: /etc/ansible/roles/role_azure_disk/tasks/main.yml:19
fatal: [dbbox8]: FAILED! => {"changed": false, "err": "Error: Could not 
stat device /dev/sdc - No such file or directory.\n", "msg": "Error while 
getting device information with parted script: '/sbin/parted -s -m /dev/sdc 
-- unit 'KiB' print'", "out": "", "rc": 1}


I suppose the issue is more related to the disk profile as opposed to the 
parted module in itself?  The disk itself was created as recommended by 
azure (
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/add-disk) 

Regards

On Monday, February 10, 2020 at 7:01:17 PM UTC, Hugo Gonzalez wrote:
>
>
> On 2/10/20 3:49 AM, 'deewon' via Ansible Project wrote:
>
> Hi all, 
>
> I'm pretty certain someone has figured this out so any hints will be 
> appreciated
>
> I've attached an  azure managed disk to a linux vm  but noticed it doesn't 
> have any disk label  i.e.
>
>
> The disk label is the partition table, and will not be recognized for an 
> unpartitioned disk. There is a parameter in the module called "label" with 
> a default of "msdos" as the table format.
>
>
> https://docs.ansible.com/ansible/latest/modules/parted_module.html#parameter-label
>
> So I guess you can pass it along your partition definitions. Just make 
> sure it works idempotently, I haven't tested it.
>
> Hugo G.
>
>
>
>
>
> Consequently, the ansible parted module returns the below error when 
> attempting to create a partition
>
> TASK [role_azure_disk : Partition Azure Disk] 
> ***
> task path: /etc/ansible/roles/role_azure_disk/tasks/main.yml:7
> fatal: [labserver]: FAILED! => {"changed": false, "err": "Error: Could not 
> stat device /dev/sdc - No such file or directory.\n", "msg": "Error while 
> getting device information with parted script: '/sbin/parted -s -m /dev/sdc 
> -- unit 'KiB' print'", "out": "", "rc": 1}
>
> To achieve idempotence when re-running playbooks , I'm trying to avoid 
> using fdisk passed to the shell module  i.e. (echo n; echo p; echo 1; echo 
> ; echo ; echo w) | sudo fdisk /dev/sdc
>
> Will appreciate any ideas on how to get around this
>
> Thanks
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to ansible...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/49c9a80b-1302-4463-a6ee-0e1a2e049e8b%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/8f3c285c-3eb7-4737-b279-e8a166144ee7%40googlegroups.com.


Re: [ansible-project] aws ec2 attach snapshot ansible playbook error message

2020-02-11 Thread Stefan Hornburg (Racke)
On 2/11/20 7:52 AM, Sandy Hung wrote:
> Dear all:
> 
> I have some problem I don't know I attach ebs from snapshot but attach show 
> error message please help thanks.
> 
> fatal: [localhost]: FAILED! => {
>     "msg": "The task includes an option with an undefined variable. The error 
> was: list object has no element 0\n\nThe
> error appears to be in '/home/sandy/aws/create-EBS.yml': line 74, column 6, 
> but may\nbe elsewhere in the file depending
> on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n   - 
> name: attach ebs volume from snapshot\n   
>  ^ here\n"
> 
>  - name: Get snapshot info
>      ec2_snapshot_info:
>        aws_access_key: "{{aws_access_key}}"
>        aws_secret_key: "{{aws_secret_key}}"
>        region: "{{ region }}"
>        filters:
>         "tag:Name": snapshot
>      register: ec2_snapshot_facts
> 
> 
> "this error

There are no results in the ec2_snapshot_facts.snapshots, thus retrieving the 
first element of this list
causing this error.

To see what is within ec2_snapshot_facts add a debug task:

- debug:
msg: "{{  ec2_snapshot_facts }}"

Regards
Racke

> 
> 
> - name: attach ebs volume from snapshot
>      ec2_vol:
>        aws_access_key: "{{ aws_access_key }}"
>        aws_secret_key: "{{ aws_secret_key }}"
>        region: "{{ region }}"
>        zone: "{{zone}}"
>        instance: "{{ instance_id }}"
>        device_name: "{{ device_name }}"
>        snapshot_ids: '{{ec2_snapshot_facts.snapshots[0].snapshot_id}}'
>        with_items: "{{instance_id}}"
> 
> -- 
> 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/d9a813cb-04b7-4c6d-9d87-eedc8b65c8cd%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/1eea8553-e33e-3a33-2da8-2961edb32873%40linuxia.de.


signature.asc
Description: OpenPGP digital signature