[ansible-project] Re: Get Field with equal condition from json generated ansible 2.5.2 uri module

2018-10-22 Thread Alberto Jimenez Lozano
It works OK, thanks.


 - name: LIST id HC
debug:
   var=hc.json.results|json_query('[?name==`{{host_collection}}`].id')


TASK [LIST id HC] 
***
ok: [] => {
"hc.json.results|json_query('[?name==`hc1`].id')": [
693
]
}

But I have another problem.
I want to use that variable for another uri execution, but i don´t know how 
to pass the value to a var.

I tried with this, but it fails:


- set_fact:
*   hc_id: 
"{{hc.json.results|json_query('[?name==`{{host_collection}}`].id')}}"*

  - name: LIST id HC
debug:
   var=hc_id

  - name: GET INFO NODES HOST COLLECTION
uri:
   url: "https://xxx/katello/api/host_collections/{{hc_id}}/";
   user: "{{user}}"
   password: "{{password}}"
   method: GET
   return_content: yes
   force_basic_auth: yes
   validate_certs: no
   headers:
   Content-Type: "application/json"
   status_code: [200,201,202,204,301,401]
register: hc_info

  - name: LIST id HC
debug:

hc_id variable is empty:

TASK [set_fact] 
*
ok: [ssh.sva.itbatera.ejgv.eus]

TASK [LIST id HC] 
***
ok: [ssh.sva.itbatera.ejgv.eus] => {
"hc_id": []
}


El lunes, 22 de octubre de 2018, 18:02:14 (UTC+2), Vladimir Botka escribió:
>
> Try
>>
>
>  - debug: var=hc.json.results|json_query('[?name==`hc1`].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 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/223685c3-be39-4492-9c0f-c8e82dd49b90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Galaxy’s new quality scoring of roles - feedback requested

2018-10-22 Thread Vladimir Botka

In response to the question "Works without change?Y/N" the owner of the 
contribution might want to know what the changes were.

Thank you!

-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 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/c12bf592-815f-492a-8151-f3d0ad5e0954%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Complex host patterns

2018-10-22 Thread Gonzalo Servat
Hi All

When working with host patterns
, is
it possible to craft one that says "must be in group X *and* must be in
either group Y, W and Z"?

e.g. host must be in group "webserver" but it *must* also be in either
group dc1, dc2 or dc3.

I can see how to check that webserver is part of dc1 (webserver,&dc1) but
not sure how to build it with multiple "OR" on the "AND" (something like
"webserver,&(dc1,dc2,dc3)" is what I'm looking for but it doesn't work)

Cheers
Gonz

-- 
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/CAHpidMB6HgesmaPPzDap6FCrb4ZtKW%2BSOuh0vq-sSyAELpVS%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Unable to parse ansible/contrib/inventory/ec2.py as an inventory source

2018-10-22 Thread Kai Stian Olstad

On 23.10.2018 03:42, heguimi...@gmail.com wrote:
When I run the following command in the directory 
ansible/contrib/inventory


ansible -i ec2.py all -m ping

and I got the following error:

[WARNING]:  * Failed to parse
/Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py with ini 
plugin:


Ansible is trying to read the content instead of executing the script 
because of missing execution bit.

So you need to set the execution bit on ec2.py to make it work.

--
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 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/478e718d7f3479017e1a1a4466518bf0%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Unable to parse ansible/contrib/inventory/ec2.py as an inventory source

2018-10-22 Thread Vladimir Botka
Odd number of the quotation marks caused the error. Fix line 3 in ec2.py

Error parsing host definition ': No closing quotation

-- 
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/88facc9e-2be1-48c9-918c-8d2cb052f66d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible Vault - store credentials for all hosts in one vault file

2018-10-22 Thread Michael Mullay
Libor,

I think what you are asking is if you can do something like this?

host1 password123
host2 password456
host3 password789

If so, then sure. Just put it in a tab-separated file and encrypt it with
ansible-encrypt and use it like you would any other variables. You could
probably use the csvfile module to call column 1 for user, column 2 for
password.



On Mon, Oct 22, 2018 at 12:57 AM Libor Burda  wrote:

> Hello everyone.
>
> Is there any way how to store credentials in one Vault file, so that these
> credentials are applied for each host?
>
> For example, when I create group_vars/all.yml and store creds here and
> then execute playbook with --limit=single_host, these credentials are not
> applied. I probably would have to create vault file for each host, but
> that's crazy when you have thousands of servers.
>
> The goal is to stop Ansible execution once you put wrong ssh password.
> Right now, Ansible tries to connect with wrong password, it fails, and our
> SIEM detects this as attack and locks the account instantly.
>
> Or is there any alternative way how to prevent this from happening?
>
> Thanks in advance.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To 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/9d1250bc-f3fc-47bd-b8b0-16a84dd193da%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 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/CAH4rTPtqHiCeLqy14jut2o9s7zDBdXfig9_At_VgyekohtYRMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Unable to parse ansible/contrib/inventory/ec2.py as an inventory source

2018-10-22 Thread heguimin36
When I run the following command in the directory ansible/contrib/inventory

ansible -i ec2.py all -m ping

and I got the following error:

[WARNING]:  * Failed to parse 
/Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py with
ini plugin: /Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py:3: 
Error parsing host
definition ': No closing quotation

 [WARNING]: Unable to parse 
/Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py as an
inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note 
that the implicit localhost does not match 'all'


My OS is MacOS and ansible version is 2.6.1. Did something or 
configurations be lost?

-- 
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/95636ab4-bf0a-4e6c-b2ce-9ca4c7a02cfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Galaxy’s new quality scoring of roles - feedback requested

2018-10-22 Thread acrosby
Ansible Galaxy 3.1 will introduce quality scoring of roles - you can try 
this out now in the galaxy dev environment: https://galaxy-dev.ansible.com.  
We hope quality scores will provide another datapoint to help users compare 
different roles.

   - On Galaxy’s import of roles we run linters (ansible-lint, yamllint, 
   and internal checks) and display any issues found. At this time scoring is 
   done only on import.
   - The ansible-lint rules used are currently located here 
   
   - The role’s content page Quality Score section displays linter issues, 
   their severity, and the resulting scores. The Quality Score is broken down 
   into, and the average of:
  - Content Score - based on linter issues related to tasks and yaml 
  formatting
  - Metadata Score - based on linter issues specific to meta/main.yml
   

Feedback is welcome, thanks!

Andrew Crosby (@awcrosby)
Ansible Galaxy Engineering

-- 
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/722da7b4-9417-459b-8297-95aa4f0a0f34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Kishore Ponniah
I managed to sort out, there is no parameter called "template_parameter"

  - name: create rxgt-ps-mgmt-direct-connect-gateway stack
aws_direct_connect_gateway:
  state: present
  region: ""
  aws_access_key: ""
  aws_secret_key: ""
  security_token: ""
  name: "{{ 
rxgt_mgmt_account.account_config.rxgtmgmt.stacks['rxgt-ps-mgmt-direct-connect-gateway'].params.name
 
}}"
  amazon_asn: "{{ 
rxgt_mgmt_account.account_config.rxgtmgmt.stacks['rxgt-ps-mgmt-direct-connect-gateway'].params.amazon_asn
 
}}"
register: created_aws_direct_connect_gateway
tags:
  rxgt-ps-mgmt-dxgw-deploy

On Monday, October 22, 2018 at 6:38:03 PM UTC+1, Kishore Ponniah wrote:
>
> ok, I used the below 
>
>   template_parameters: "{{ 
> rxgt_mgmt_account.account_config.rxgtmgmt.stacks['rxgt-ps-mgmt-direct-connect-gateway'].params
>  
> }}"
>   tags: "{{ global_tags | 
> combine(rxgt_mgmt_account.account_config.rxgtmgmt.stacks['rxgt-ps-mgmt-direct-connect-gateway'].override_tags,
>  
> recursive=True) }}"
>
> TASK [create rxgt-ps-mgmt-direct-connect-gateway stack] 
> 
> fatal: [infrastructure]: FAILED! => {"msg": "|combine expects 
> dictionaries, got Undefined"}
> to retry, use: --limit @/home/ec2-user/.ansible-retry/site.retry
>
> On Monday, October 22, 2018 at 5:06:42 PM UTC+1, Tony Chia wrote:
>>
>> It seems there is one level between account_config and stack.
>> Maybe try account_config.xx.stacks instead? 
>>
>> On Monday, October 22, 2018 at 5:17:31 AM UTC-7, Kishore Ponniah wrote:
>>>
>>> Hi, 
>>>
>>> I am trying to create a Direct connect Gateway in AWS account using 
>>> ansible. I have the main playbook and an account config yaml template. When 
>>> I run the playbook I am getting an error 
>>>
>>> fatal: [infrastructure]: FAILED! => {"msg": "The task includes an option 
>>> with an undefined variable. The error was: 'dict object' has no attribute 
>>> 'stacks'\n\nThe error appears to have been in 
>>> '/home/ec2-user/environment/aws-rxgt-mgmt-platform/ansible/rxgt-ps-rxgtmgmt-playbook.yaml':
>>>  
>>> line 10, 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: 
>>> create rxgt-ps-mgmt-direct-connect-gateway stack\n^ here\n"}
>>>
>>> I have attached the code for reference and error. can someone please 
>>> help?
>>>
>>>
>>> Thanks
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/dcb6e609-2989-4d96-a598-3dbf2c49a8bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Help needed Please ...

2018-10-22 Thread Satesh S Kumar
Thanks for the suggestion.

On Sunday, 21 October 2018 23:59:17 UTC-7, Oriol Tauleria wrote:
>
> Hello Satesh,
> your problem is that you are trying to define win_roles as an attribute 
> and this didn't work like that. 
> You need to define win_roles as a variable, and then use it with a loop or 
> with_items or similar.
> You can do something like (changing debug for win_feature and the other 
> params):
>
> ---
> - 
> hosts: my_server
> name: "Install Roles and Features"
> vars:
> win_roles:
> - "Web-Server"
> - "Web-WebServer"
> tasks: 
> - debug:
> msg: "{{ item }}"
> with_items:
> - "{{ win_roles }}"
>
>
> El lun., 22 oct. 2018 a las 4:37, Satesh S Kumar ( >) escribió:
>
>> Hi,
>>
>> I am trying to install IIS and sub features via Ansible.  It gives me the 
>> below error. I have Ansible 2.4. Please let me know if you got any pointers 
>> ...
>>
>>
>> ERROR! 'win_roles' is not a valid attribute for a Play
>>
>> --- 
>> - 
>>   hosts: my_server
>>   name: "Install Roles and Features"
>>   tasks: 
>> - 
>>   include_management_tools: true
>>   name: "{{ item }}"
>>   restart: true
>>   state: present
>>   win_feature: ~
>>   with_items: " {{ win_roles }} "
>>   win_roles: 
>> - Web-Server
>> - Web-WebServer
>> - Web-Common-Http
>> - Web-Default-Doc
>> - Web-Dir-Browsing
>> - Web-Http-Errors 
>>
>> -- 
>> 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-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/9f016c20-9f62-46a0-bc83-97dce85eff59%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 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/c57b05d5-9eb0-4aae-b03f-cfa31d798479%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Kishore Ponniah
ok, I used the below 

  template_parameters: "{{ 
rxgt_mgmt_account.account_config.rxgtmgmt.stacks['rxgt-ps-mgmt-direct-connect-gateway'].params
 
}}"
  tags: "{{ global_tags | 
combine(rxgt_mgmt_account.account_config.rxgtmgmt.stacks['rxgt-ps-mgmt-direct-connect-gateway'].override_tags,
 
recursive=True) }}"

TASK [create rxgt-ps-mgmt-direct-connect-gateway stack] 

fatal: [infrastructure]: FAILED! => {"msg": "|combine expects dictionaries, 
got Undefined"}
to retry, use: --limit @/home/ec2-user/.ansible-retry/site.retry

On Monday, October 22, 2018 at 5:06:42 PM UTC+1, Tony Chia wrote:
>
> It seems there is one level between account_config and stack.
> Maybe try account_config.xx.stacks instead? 
>
> On Monday, October 22, 2018 at 5:17:31 AM UTC-7, Kishore Ponniah wrote:
>>
>> Hi, 
>>
>> I am trying to create a Direct connect Gateway in AWS account using 
>> ansible. I have the main playbook and an account config yaml template. When 
>> I run the playbook I am getting an error 
>>
>> fatal: [infrastructure]: FAILED! => {"msg": "The task includes an option 
>> with an undefined variable. The error was: 'dict object' has no attribute 
>> 'stacks'\n\nThe error appears to have been in 
>> '/home/ec2-user/environment/aws-rxgt-mgmt-platform/ansible/rxgt-ps-rxgtmgmt-playbook.yaml':
>>  
>> line 10, 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: 
>> create rxgt-ps-mgmt-direct-connect-gateway stack\n^ here\n"}
>>
>> I have attached the code for reference and error. can someone please help?
>>
>>
>> Thanks
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/dda6c359-92d8-40ee-8a9b-53de098106a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Vault - store credentials for all hosts in one vault file

2018-10-22 Thread Tony Chia
You can try to add "serial: 1" to your play in your playbook so if it fails 
to ssh to first host, it won't try to connect to the 2nd host. 
By default, it tries to connect 5 hosts at a time and usually that is 
enough to trigger the account to be locked. 

Regards,
Tony Chia

On Monday, October 22, 2018 at 12:57:43 AM UTC-7, Libor Burda wrote:
>
> Hello everyone.
>
> Is there any way how to store credentials in one Vault file, so that these 
> credentials are applied for each host?
>
> For example, when I create group_vars/all.yml and store creds here and 
> then execute playbook with --limit=single_host, these credentials are not 
> applied. I probably would have to create vault file for each host, but 
> that's crazy when you have thousands of servers.
>
> The goal is to stop Ansible execution once you put wrong ssh password. 
> Right now, Ansible tries to connect with wrong password, it fails, and our 
> SIEM detects this as attack and locks the account instantly.
>
> Or is there any alternative way how to prevent this from happening?
>
> Thanks in advance.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/77eaba12-60cc-46b6-b7b2-2ec6cb9973e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Tony Chia
It seems there is one level between account_config and stack.
Maybe try account_config.xx.stacks instead? 

On Monday, October 22, 2018 at 5:17:31 AM UTC-7, Kishore Ponniah wrote:
>
> Hi, 
>
> I am trying to create a Direct connect Gateway in AWS account using 
> ansible. I have the main playbook and an account config yaml template. When 
> I run the playbook I am getting an error 
>
> fatal: [infrastructure]: FAILED! => {"msg": "The task includes an option 
> with an undefined variable. The error was: 'dict object' has no attribute 
> 'stacks'\n\nThe error appears to have been in 
> '/home/ec2-user/environment/aws-rxgt-mgmt-platform/ansible/rxgt-ps-rxgtmgmt-playbook.yaml':
>  
> line 10, 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: 
> create rxgt-ps-mgmt-direct-connect-gateway stack\n^ here\n"}
>
> I have attached the code for reference and error. can someone please help?
>
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/ae773426-3bfc-49ac-8d5f-9e087abc345b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Get Field with equal condition from json generated ansible 2.5.2 uri module

2018-10-22 Thread Vladimir Botka

>
> Try
>

 - debug: var=hc.json.results|json_query('[?name==`hc1`].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 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/c2d1b898-4b67-45f3-a3cf-8d2837732636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Kishore Ponniah
I did -vvv and I don't see anything different. Same error and it gathered 
the facts. Not sure if my debug stack task is correct. 

On Monday, October 22, 2018 at 2:37:50 PM UTC+1, Adrian Sebastian Dutu 
wrote:
>
> I think the indentation appears wrong just in the preview. I downloaded 
> the file and the indentation is fine on line 10.
> It seems this line is the 
> issue: 
> combine(rxgt_mgmt_account.account_config.stacks['rxgt-ps-mgmt-direct-connect-gateway'].override_tags,
>  
> recursive=True) }}"
> It says that dictionary has no key named stacks. Maybe try just printing 
> that dict or do -vvv to see what keys that it actually has.
>

-- 
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/f2db6462-3d62-4892-baa2-b6db7e67593e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Get Field with equal condition from json generated ansible 2.5.2 uri module

2018-10-22 Thread Alberto Jimenez Lozano


I need get a field into a json what has been generated wit uri module.

This is my json that contains two hosts colections hc1 y hc2.
I want to get the field id:693 of the host_collection hc1.

"created_at": "2018-10-18 13:29:01 UTC", 
"description": null, 
"id": 693, 
"max_hosts": null, 
"name": "hc1", 
"organization_id": 1, 
"permissions": {
"deletable": true, 
"editable": true
}, 
"total_hosts": 0, 
"unlimited_hosts": true, 
"updated_at": "2018-10-18 13:29:01 UTC"
}, 
{
"created_at": "2018-10-18 13:29:04 UTC", 
"description": null, 
"id": 696, 
"max_hosts": null, 
"name": "hc2", 
"organization_id": 1, 
"permissions": {
"deletable": true, 
"editable": true
}, 
"total_hosts": 0, 
"unlimited_hosts": true, 
"updated_at": "2018-10-18 13:29:04 UTC"
}, 

My playbook is this, but it fails.

 - name: GET consulta api satellite
uri:
   url: "https://xx/katello/api/host_collections/";
   user: "{{user}}"
   password: "{{password}}"
   method: GET
   return_content: yes
   force_basic_auth: yes
   validate_certs: no
   headers:
   Content-Type: "application/json"
   status_code: [200,201,202,204,301,401]
register: hc

  - name: GET ID d HC

debug: 
   var="hc.json.results.[?name=='hc1'].id"



When I execute de playbook, it appears the next error:

TASK [GET ID del HC] 
***
fatal: []: FAILED! => {}

MSG:

template error while templating string: unexpected char u'?' at 19. String: 
{{hc.json.results.[?name=='hc1'].id}}
to retry, use: --limit 
@/awx/scripts/sat_uri/mb_get_host_collection.retry

If I put this option, go OK.

- name: GET ID del HC
debug:
   var=hc.json.results[0].id
 

**TASK [GET ID del HC] 
***
ok: [] => {
"hc.json.results[0].id": "693"
}**


-- 
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/b626e099-c91d-465e-a0f3-6d5cabde837b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Adrian Sebastian Dutu
I think the indentation appears wrong just in the preview. I downloaded the 
file and the indentation is fine on line 10.
It seems this line is the 
issue: 
combine(rxgt_mgmt_account.account_config.stacks['rxgt-ps-mgmt-direct-connect-gateway'].override_tags,
 
recursive=True) }}"
It says that dictionary has no key named stacks. Maybe try just printing 
that dict or do -vvv to see what keys that it actually has.

-- 
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/3bb5259e-ae7e-4db5-842a-77a6fd3149f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Kishore Ponniah
I have corrected that. I am concerned if line 17 is correct

Thanks

On Monday, October 22, 2018 at 2:32:27 PM UTC+1, Vladimir Botka wrote:
>
>
> The indentation is wrong (line 10, column 5). Should be:
>
> tasks:
>
>   - name: create rxgt-ps-mgmt-direct-connect-gateway stack
>
>
>

-- 
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/4e3b170d-c1f7-4e07-9987-6ec4a1d5b4df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Vladimir Botka

The indentation is wrong (line 10, column 5). Should be:

tasks:

  - name: create rxgt-ps-mgmt-direct-connect-gateway stack


-- 
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/675c9dad-5b14-46c9-9c7d-452247899ee1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Kishore Ponniah
main playbook code

---
# This playbook builds Network infrastructure in all configured accounts
- name: Install/Update RXGT Mgmt account CF templates
hosts: infrastructure
tasks:

- name: Install/Update RXGT PS cross account CF templates
hosts: infrastructure
tasks:
- name: create rxgt-ps-mgmt-direct-connect-gateway stack
aws_direct_connect_gateway:
state: present
region: ""
aws_access_key: ""
aws_secret_key: ""
security_token: ""
template_parameters: "{{ 
rxgt_mgmt_account.account_config.stacks['rxgt-ps-mgmt-direct-connect-gateway'].params
 
}}"
tags: "{{ global_tags | 
combine(rxgt_mgmt_account.account_config.stacks['rxgt-ps-mgmt-direct-connect-gateway'].override_tags,
 
recursive=True) }}"
register: created_aws_direct_connect_gateway
tags:
rxgt-ps-mgmt-dxgw-deploy

- name: debug stack outputs
vars:
msg: "{{ account_config | to_nice_yaml }}"
debug:
msg: "{{ msg.split('\n') }}"
verbosity: 0
tags:
- 'never'
- 'debug'
- rxgt-ps-mgmt-dxgw-deploy

account_config code:

---
ansible_python_interpreter: "{{ lookup('env', 'VIRTUAL_ENV') }}/bin/python"
rxgt_mgmt_account:
deploy_accounts:
- xx

account_config:
xx:
id: xx
account_alias: xx
sts_role_arn: 
arn:aws:iam::xxx:role/x/xx/xx
pass_role_arn: ""
regions:
- eu-west-1
stacks:
rxgt-ps-mgmt-direct-connect-gateway:
params:
name: mgmt-dxgw
amazon_asn: 65000
override_tags:
rx:billing:service-name: identity
rx:billing:environment-name: xxx

On Monday, October 22, 2018 at 1:17:31 PM UTC+1, Kishore Ponniah wrote:
>
> Hi, 
>
> I am trying to create a Direct connect Gateway in AWS account using 
> ansible. I have the main playbook and an account config yaml template. When 
> I run the playbook I am getting an error 
>
> fatal: [infrastructure]: FAILED! => {"msg": "The task includes an option 
> with an undefined variable. The error was: 'dict object' has no attribute 
> 'stacks'\n\nThe error appears to have been in 
> '/home/ec2-user/environment/aws-rxgt-mgmt-platform/ansible/rxgt-ps-rxgtmgmt-playbook.yaml':
>  
> line 10, 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: 
> create rxgt-ps-mgmt-direct-connect-gateway stack\n^ here\n"}
>
> I have attached the code for reference and error. can someone please help?
>
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/6ed85d43-591b-468c-91dd-371f371ebe0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible Playbook error - Dict object has no attribute.

2018-10-22 Thread Kishore Ponniah
Hi, 

I am trying to create a Direct connect Gateway in AWS account using 
ansible. I have the main playbook and an account config yaml template. When 
I run the playbook I am getting an error 

fatal: [infrastructure]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: 'dict object' has no attribute 
'stacks'\n\nThe error appears to have been in 
'/home/ec2-user/environment/aws-rxgt-mgmt-platform/ansible/rxgt-ps-rxgtmgmt-playbook.yaml':
 
line 10, 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: 
create rxgt-ps-mgmt-direct-connect-gateway stack\n^ here\n"}

I have attached the code for reference and error. can someone please help?


Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/6cf10910-5f3d-473e-b7b5-36b3ee96246b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible mail module failing at sending mail

2018-10-22 Thread Umberto Manferdini
Thanks all,
a colleague of mine pointed to the solution
https://stackoverflow.com/questions/40904957/send-email-using-my-yahoo-account-error-message
some mail services require 2FA and per-app passwords

now it is working!
Umberto
Il giorno sabato 20 ottobre 2018 22:51:43 UTC+2, Sathya Narayanan ha 
scritto:
>
> Hi Umberto, 
>
> Just a quick thought, if you have any special character in your password, 
> try searching them.
>
> Some times -$ symbols are not valid when you pass that as a vatiable.
>
> I am not sure if that can fix your problem, but just a suggestion.
>
> On Fri, 19 Oct 2018, 8:25 pm Umberto Manferdini,  > wrote:
>
>> Hello,
>>
>> Trying to use the mail module to send emails as last task of my playbook
>>
>>  
>>
>> It fails saying
>>
>>
>> fatal: [r1 -> localhost]: FAILED! => {"changed": false, "msg": 
>> "Authentication to smtp.mail.yahoo.com:25 failed, please check your 
>> username and/or password", "rc": 1}
>>
>> even if i'm totally sure credentials are right
>>
>>  
>>
>> As I imagine, underneath, it relies on on the smtplib python module , I 
>> tried to do it manually
>>
>>  
>>
>> I get this
>>
>>  
>>
>> >>> server = smtplib.SMTP('smtp.mail.yahoo.com', 25)
>>
>>  
>>
>> >>> server.connect('smtp.mail.yahoo.com', 25)
>>
>> Traceback (most recent call last):
>>
>>   File "", line 1, in 
>>
>>   File "/usr/lib/python2.7/smtplib.py", line 317, in connect
>>
>> (code, msg) = self.getreply()
>>
>>   File "/usr/lib/python2.7/smtplib.py", line 368, in getreply
>>
>> raise SMTPServerDisconnected("Connection unexpectedly closed")
>>
>> smtplib.SMTPServerDisconnected: Connection unexpectedly closed
>>
>>  
>>
>> >>> server.connect('smtp.mail.yahoo.com', 25)
>>
>> (220, 'smtp.mail.yahoo.com ESMTP ready')
>>
>>  
>>
>> >>> server.ehlo()
>>
>> (250, 'smtp431.mail.ir2.yahoo.com Hello*** 
>> [***])\nPIPELINING\nENHANCEDSTATUSCODES\n8BITMIME\nSIZE 41697280\nSTARTTLS')
>>
>>  
>>
>> >>> server.login("*** ","***")
>>
>> Traceback (most recent call last):
>>
>>   File "", line 1, in 
>>
>>   File "/usr/lib/python2.7/smtplib.py", line 585, in login
>>
>> raise SMTPException("SMTP AUTH extension not supported by server.")
>>
>> smtplib.SMTPException: SMTP AUTH extension not supported by server.
>>
>>  
>>
>>- -  I can create the object
>>- -  First connect fails
>>- -  Second is ok
>>- -  Ehlo is fine
>>- -  Login fails
>>
>>  
>>
>> Same happens with other smtp servers 
>>
>>  
>>
>> Moreover, If I try to create the server towards port 465 it fails at step 
>> 1
>>
>>  
>>
>> >>> server = smtplib.SMTP('smtp.mail.yahoo.com', 465)
>>
>> Traceback (most recent call last):
>>
>>   File "", line 1, in 
>>
>>   File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
>>
>> (code, msg) = self.connect(host, port)
>>
>>   File "/usr/lib/python2.7/smtplib.py", line 317, in connect
>>
>> (code, msg) = self.getreply()
>>
>>   File "/usr/lib/python2.7/smtplib.py", line 368, in getreply
>>
>> raise SMTPServerDisconnected("Connection unexpectedly closed")
>>
>> smtplib.SMTPServerDisconnected: Connection unexpectedly closed
>>
>>  
>>
>> has anyone encountered this before?
>>
>>
>> task is
>>
>>
>> - name: Sending an e-mail 
>>   mail:
>> host: smtp.mail.yahoo.com
>> port: 25
>> username: "***"
>> password: "***"
>> to: ***
>> subject: Ansible-report
>> body: "report generated"
>> attach:
>>   - "sanity_report.csv"
>>   - "{{playbook_dir}}/outputs.tgz"
>>   delegate_to: localhost
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/22818f52-2dfd-427a-b25c-dc49dba84517%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 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/b8ddec17-401b-419f-98f4-09aaa01ee5b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible to adopt molecule and ansible-lint projects.

2018-10-22 Thread jobarker


Overview

As previously announced, Ansible has adopted upstream maintenance for 
ansible-lint and Molecule. See Sept 26th mailing list post 
 for 
the background.

What will change:

   - 
   
   GitHub repos for both projects
   - 
  
  github.com/willthames/ansible-lint/ will move to 
  github.com/ansible/ansible-lint[1] 
  
  - 
  
  github.com/metacloud/molecule will move to 
  github.com/ansible/molecule[1] 
  
  - 
  
  All history (including Issues & PRs) will be migrated
  - 
   
   Docker location for Molecule
   - 
  
  Docker image will be published to quay.io/repository/molecule [1]
  - 
  
  The existing https://hub.docker.com/r/retr0h/molecule/ will not 
  receive further updates.
  Details on how pull from the new location will be included in follow 
  up email
  

What will remain the same:

   - 
   
   *Molecule*
   - 
  
  PyPi package name molecule 
  - 
 
 Continue to install with pip install molecule
 - 
 
 Upgrade from previous versions seamlessly
 - 
  
  Documentation at https://molecule.readthedocs.io/en/latest/ 
  - 
  
  Community communications
  - 
 
 https://groups.google.com/forum/#!forum/molecule-users
 - 
 
 #molecule-users on Freenode IRC
 - 
   
   *Ansible-lint*
   - 
  
  PyPi package name ansible-lint 
  - 
 
 Continue to install with pip install ansible-lint
 - 
 
 Upgrade from previous versions seamlessly
 

Timing and next steps

We will move the GitHub repos and make the associated updates the week of 
29th October. Once the repo move has been completed and documentation has 
been rebuilt we will release new versions of both projects. We’ll send 
release announcements to the ansible-announce mailing list 
 and to the 
relevant community lists.

What you will need to do after the changes:

   - 
   
   If you've checked out the code for either project, you’ll need to update 
   your git remote. 
   - 
   
   If you’re using Molecule from hub.docker.com, you’ll need to to update 
   your docker registry. 
   - 
   
   We’ll provide more details when the changes have been made.
   

To find out more

Subscribe to the ansible-announce mailing list 


Kind regards,
John "gundalow" Barker
Ansible by Red Hat


[1] Note, that these new URLs will not exist till the move is complete

-- 
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/a80d3fd1-a4e1-4055-8118-6d705f804298%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Get IP address, replace first three octets

2018-10-22 Thread Brad Van Orden
Not an ansible response (use command or shell to execute), but can retrieve 
the iLO network settings and change with:

# This is coded against iLO4!
# Run as root
cd /var/tmp # or where ever you would like to have your temporary files
#
# Get the current configuration
#
hponcfg --writeconfig ilo
#
# Delete the directory information and user information portions of the xml 
file.
#
sed -i '/^  |" ilo
#
# Write the new ip to the iLO
#
hponcfg --file ilo



On Saturday, October 20, 2018 at 11:38:38 AM UTC-4, LJ Medina wrote:
>
> Hello,
> I'm trying to assign ILO IP addresses to a range of systems, using a 
> different subnet than their host IP, just matching the fourth octet.  For 
> example, if their IP would be 10.10.10.10, I want their ILO IP to be 
> 11.11.11.10.( Plan is to use "hponcfg" module to configure the host's ILO 
> after I obtain this address)
> What is the best way to achieve this 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 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/a3d5783b-cb70-466d-b99c-22911190da94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible Vault - store credentials for all hosts in one vault file

2018-10-22 Thread Libor Burda
Hello everyone.

Is there any way how to store credentials in one Vault file, so that these 
credentials are applied for each host?

For example, when I create group_vars/all.yml and store creds here and then 
execute playbook with --limit=single_host, these credentials are not 
applied. I probably would have to create vault file for each host, but 
that's crazy when you have thousands of servers.

The goal is to stop Ansible execution once you put wrong ssh password. 
Right now, Ansible tries to connect with wrong password, it fails, and our 
SIEM detects this as attack and locks the account instantly.

Or is there any alternative way how to prevent this from happening?

Thanks in advance.


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/9d1250bc-f3fc-47bd-b8b0-16a84dd193da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.