[ansible-project] Re: Has anyone connected Riverbed (network device) thru Ansible?

2020-06-23 Thread rajthecomputerguy
Any help?

On Thursday, April 23, 2020 at 6:29:13 PM UTC+5:30, rajthecomputerguy wrote:
>
> Hi Team,
>
> Has anyone connected Riverbed (network device) thru Ansible? like using 
> command module or cli_command. 
>
> Thanks
>

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


Re: [ansible-project] Question on using the Ansible API

2020-06-23 Thread Pshem Kowalczyk
Hi,

I had a similar requirement, but decided to approach it a bit differently.
In my case the playbook always had to be run first, so I simply collected
all the variables I needed into one dictionary and then stored that
dictionary in a file for further reuse by other components.

kind regards
Pshem


On Wed, 24 Jun 2020 at 03:54, tterr...@gmail.com 
wrote:

> I have a big ansible project where I have separated my files into
> playbooks, vars files, an inventory folder and roles. These files make
> extensive use of jinja templates.
>
> For my use case, I need to be able to access the variables in these files
> outside ansible. So far, I have included `copy` tasks to dump the variable
> I need to templated out vars files. Then, in my app I read those with the
> python `yaml` module without issue since they are free of jinja templates.
> The variables I am interested in are the variables in the `vars` section of
> a playbook as well as those in `vars_files`. Such variables, get merged
> with role defaults.
>
> I am now trying to remove those `copy` tasks and instead use the Ansible
> API to get the final value for the variables. This will also have the
> benefit of fully respecting the precedence rules baked into Ansible. So
> far, this is what I have come up with.
>
> ```
> #!/usr/bin/env python
>
> import code
> import os
> import readline
> import rlcompleter
>
> os.environ["ANSIBLE_CONFIG"] = "ansible/ansible.cfg"
>
> import ansible.constants as C
> from ansible.inventory.manager
> import InventoryManager
> from ansible.parsing.dataloader import DataLoader
> from ansible.vars.manager import VariableManager
> from ansible.template import Templar
>
> from ansible.playbook import Playbook
>
> loader = DataLoader()
> inventory = InventoryManager( loader=loader,
> sources=["data/worlds/active/inventory/configs"] )
> variable_manager = VariableManager(loader=loader, inventory=inventory)
>
> p = Playbook.load( "ansible/plays/instances/main.yml", loader=loader,
> variable_manager=variable_manager)
>
> readline.parse_and_bind("tab: complete")
> code.InteractiveConsole(locals=globals()).interact()
> ```
>
> I don't know how to proceed. I am supposed to actually run the tasks in
> the playbook to manage to get the variables? Can I somehow achieve what I
> want with the Ansible API without running any task? I don't care about
> `set_fact` or dynamic creation/alteration of the variables.
>
> --
> 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/130c4ab9-028f-4c20-8802-04a8691dcc2fn%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/CAMFQMATM2s9XAMuCLv-EbGgMW7HU2s-baCmOsq%3DDFZcp-ifWJg%40mail.gmail.com.


[ansible-project] Re: Using fact as loop control in Jinja2 template

2020-06-23 Thread harry devine
Perfect  Exactly what I needed. 

Thank you very much!
Harry

On Tuesday, June 23, 2020 at 2:52:38 PM UTC-4, harry devine wrote:
>
> I have a playbook that will use the user_find API call against our FreeIPA 
> server to retrieve a list of all users.  What I'm trying to do is get the 
> total count, then use that count in my j2 file.  I'm getting the count as 
> follows:
>
> - name: Set IDM facts
>   set_fact:
> idmcount: "{{ userfind.json.result.count|int }}"
>
> - name: Output data
>   template:
> src: uid.csv.j2
> dest: uid.csv
>
>
> In my j2 file, I've tried 2 different things:
>
> Option 1:
> {% for i in idmcount %}
> {{ i }}
> {% endfor %}
>
> This prints the count as strings (the value is 1740):
> 1
> 7
> 4
> 0
>
> Option 2:
> {% for i in {{ idmcount }} %}
> {{ i }}
> {% endfor %}
>
> This gives me the following error:
> fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError: 
> template error while templating string: expected token ':', got '}'. 
> String: {% for i in {{ idmcount }} %}\n{{ i }}\n{% endfor %}\n"}
>
> So how do I use that count as a loop control variable?
>
> Thanks,
> Harry
>
>

-- 
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/7c6ace1f-1050-49d9-a140-56d3ce7520d9o%40googlegroups.com.


Re: [ansible-project] Re: Using fact as loop control in Jinja2 template

2020-06-23 Thread Matt Martz
It sounds like you have a data structure like this:

users
  - uid:
  - name1
uidnumber:
  - 

In which case I'd recommend:

users
  - uid: name1
uidnumber: 

Otherwise, You would need to use something like:  {{ users[i].uid[0] }}





On Tue, Jun 23, 2020 at 2:31 PM harry devine  wrote:

> Thank you!  That worked well.  I must've really been over thinking it.
> However, this does lead to another question:  now I'm putting in the actual
> content as follows:
>
> {% for i in range(1, idmcount|int +1) %}
> {{ users[i].uid }},{{ users[i].uidnumber }}
> {% endfor %}
>
> This works fine, but the values appear to be in (what I think) is the json
> format.  For example:
>
> [u'name1'],[u'']
>
> How do I strip out the "u'" and have just:
> name,
>
> Thanks,
> Harry
> On Tuesday, June 23, 2020 at 2:52:38 PM UTC-4, harry devine wrote:
>>
>> I have a playbook that will use the user_find API call against our
>> FreeIPA server to retrieve a list of all users.  What I'm trying to do is
>> get the total count, then use that count in my j2 file.  I'm getting the
>> count as follows:
>>
>> - name: Set IDM facts
>>   set_fact:
>> idmcount: "{{ userfind.json.result.count|int }}"
>>
>> - name: Output data
>>   template:
>> src: uid.csv.j2
>> dest: uid.csv
>>
>>
>> In my j2 file, I've tried 2 different things:
>>
>> Option 1:
>> {% for i in idmcount %}
>> {{ i }}
>> {% endfor %}
>>
>> This prints the count as strings (the value is 1740):
>> 1
>> 7
>> 4
>> 0
>>
>> Option 2:
>> {% for i in {{ idmcount }} %}
>> {{ i }}
>> {% endfor %}
>>
>> This gives me the following error:
>> fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError:
>> template error while templating string: expected token ':', got '}'.
>> String: {% for i in {{ idmcount }} %}\n{{ i }}\n{% endfor %}\n"}
>>
>> So how do I use that count as a loop control variable?
>>
>> Thanks,
>> Harry
>>
>> --
> 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/3f29473b-32e2-4e64-a0f3-f446d4156a2co%40googlegroups.com
> 
> .
>


-- 
Matt Martz
@sivel
sivel.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/CAD8N0v8Q3KE%3DkADX%3DFr8ws6erWJQw-%2BXpqkPgNFR_qC%3DW6B-Fg%40mail.gmail.com.


[ansible-project] Re: Using fact as loop control in Jinja2 template

2020-06-23 Thread harry devine
Thank you!  That worked well.  I must've really been over thinking it.  
However, this does lead to another question:  now I'm putting in the actual 
content as follows:

{% for i in range(1, idmcount|int +1) %}
{{ users[i].uid }},{{ users[i].uidnumber }}
{% endfor %}

This works fine, but the values appear to be in (what I think) is the json 
format.  For example:

[u'name1'],[u'']

How do I strip out the "u'" and have just:
name,

Thanks,
Harry
On Tuesday, June 23, 2020 at 2:52:38 PM UTC-4, harry devine wrote:
>
> I have a playbook that will use the user_find API call against our FreeIPA 
> server to retrieve a list of all users.  What I'm trying to do is get the 
> total count, then use that count in my j2 file.  I'm getting the count as 
> follows:
>
> - name: Set IDM facts
>   set_fact:
> idmcount: "{{ userfind.json.result.count|int }}"
>
> - name: Output data
>   template:
> src: uid.csv.j2
> dest: uid.csv
>
>
> In my j2 file, I've tried 2 different things:
>
> Option 1:
> {% for i in idmcount %}
> {{ i }}
> {% endfor %}
>
> This prints the count as strings (the value is 1740):
> 1
> 7
> 4
> 0
>
> Option 2:
> {% for i in {{ idmcount }} %}
> {{ i }}
> {% endfor %}
>
> This gives me the following error:
> fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError: 
> template error while templating string: expected token ':', got '}'. 
> String: {% for i in {{ idmcount }} %}\n{{ i }}\n{% endfor %}\n"}
>
> So how do I use that count as a loop control variable?
>
> Thanks,
> Harry
>
>

-- 
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/3f29473b-32e2-4e64-a0f3-f446d4156a2co%40googlegroups.com.


Re: [ansible-project] Using fact as loop control in Jinja2 template

2020-06-23 Thread Matt Martz
Do you want to loop over a range of numbers up to idmcount?  I think that
is what I am reading, in which case you want:

{% for i in range(1, idmcount|int + 1) %}

On Tue, Jun 23, 2020 at 1:52 PM harry devine  wrote:

> I have a playbook that will use the user_find API call against our FreeIPA
> server to retrieve a list of all users.  What I'm trying to do is get the
> total count, then use that count in my j2 file.  I'm getting the count as
> follows:
>
> - name: Set IDM facts
>   set_fact:
> idmcount: "{{ userfind.json.result.count|int }}"
>
> - name: Output data
>   template:
> src: uid.csv.j2
> dest: uid.csv
>
>
> In my j2 file, I've tried 2 different things:
>
> Option 1:
> {% for i in idmcount %}
> {{ i }}
> {% endfor %}
>
> This prints the count as strings (the value is 1740):
> 1
> 7
> 4
> 0
>
> Option 2:
> {% for i in {{ idmcount }} %}
> {{ i }}
> {% endfor %}
>
> This gives me the following error:
> fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError:
> template error while templating string: expected token ':', got '}'.
> String: {% for i in {{ idmcount }} %}\n{{ i }}\n{% endfor %}\n"}
>
> So how do I use that count as a loop control variable?
>
> Thanks,
> Harry
>
> --
> 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/a1c3ce58-af3c-4f84-bad2-9cfbbbaf2fb2o%40googlegroups.com
> 
> .
>


-- 
Matt Martz
@sivel
sivel.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/CAD8N0v-HkwnNRssV8r-gqn986ZH7tDFU7JbMK0jn%3DLqC-QL96A%40mail.gmail.com.


[ansible-project] Using fact as loop control in Jinja2 template

2020-06-23 Thread harry devine
I have a playbook that will use the user_find API call against our FreeIPA 
server to retrieve a list of all users.  What I'm trying to do is get the 
total count, then use that count in my j2 file.  I'm getting the count as 
follows:

- name: Set IDM facts
  set_fact:
idmcount: "{{ userfind.json.result.count|int }}"

- name: Output data
  template:
src: uid.csv.j2
dest: uid.csv


In my j2 file, I've tried 2 different things:

Option 1:
{% for i in idmcount %}
{{ i }}
{% endfor %}

This prints the count as strings (the value is 1740):
1
7
4
0

Option 2:
{% for i in {{ idmcount }} %}
{{ i }}
{% endfor %}

This gives me the following error:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "AnsibleError: 
template error while templating string: expected token ':', got '}'. 
String: {% for i in {{ idmcount }} %}\n{{ i }}\n{% endfor %}\n"}

So how do I use that count as a loop control variable?

Thanks,
Harry

-- 
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/a1c3ce58-af3c-4f84-bad2-9cfbbbaf2fb2o%40googlegroups.com.


Fwd: [ansible-project] Ansible to connect to certain switchports on Cisco 2960

2020-06-23 Thread J C
Well at this point I would probably remove genie.  Then create a virtual
python environment.  Run the pip install commands and see if that works for
you.  If you are still running into issues I would reach out to the guys
who made genie - I think Clay is in the group there too.

https://eurl.io/#r18UzrQVr



-- Forwarded message -
From: Jason 
Date: Tue, Jun 23, 2020, 12:30 PM
Subject: Re: [ansible-project] Ansible to connect to certain switchports on
Cisco 2960
To: Ansible Project 


I added it. Now, this shows:

fatal: [SW1]: FAILED! => {
*"msg": "parse_genie: Genie package is not installed. To install, run
'pip install genie'."*
}

When I do pip or pip3 install genie, it says requirements already satisfied
(as I already installed it).

Just to show you what my directories look like:

[image: directory genie.JPG]

And under [defaults] in my ansible.cfg:

*collections_paths = /etc/ansible/collections/ansible_collections/*

Tried putting a less specific and then a more specifc path to the
collections folder also. (= /etc/ansible/collections, =
/etc/ansible/collections/ansible_collections/clay584/genie)

Before this, I did a * ansible-galaxy collection install clay584.genie* to
install the collection and it said this:
Installing 'clay584.genie:0.1.11' to
'/root/.ansible/collections/ansible_collections/clay584/genie'

Did I do anything wrong?


On Tuesday, June 23, 2020, at 11:34:31 AM UTC-4, J C wrote:
>
> You need to add a new line under [defaults]
>
> collections_paths = /path/to/collections
>
> On Tue, Jun 23, 2020 at 10:29 AM Jason  wrote:
>
>> No I have never used a collection before. So my ansible.cfg is currently
>> to the default
>>
>> On Tuesday, June 23, 2020 at 11:22:11 AM UTC-4, J C wrote:
>>>
>>> Not sure it seems like it is looking for the filter.  Have you used a
>>> collection before?  Is the collections_path defined in the ansible.cfg?
>>>
>>> On Mon, Jun 22, 2020 at 3:49 PM Jason  wrote:
>>>
 This error shows:
 fatal: [SW1]: FAILED! => {"msg": "template error while templating
 string: no filter named 'clay584.genie.parse_genie'. String: {{
 neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp
 neighbors', os='ios') }}"}


 This is the full playbook I am using:
 ---
 - name: Interface Descrpitions
   hosts: uwioc-switches
   gather_facts: no
   connection: network_cli
   collections:
 - clay584.genie
   vars:
 ansible_python_interpreter: "{{ ansible_playbook_python }}"
   tasks:
 - name: Run show cdp neighbors
   ios_command:
 commands:
   - show cdp neighbors
   register: neighbors
 # Using the Genie Filter Plugin from the Genie Parse Role
 # Set pyats_neighbors as a dictionary
 - name: Set fact with Genie Filter Plugin
   set_fact:
pyats_neighbors: "{{ neighbors['stdout'][0] |
 clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"


 Tried changing vars to set_facts too, but didn't work.

 On Monday, June 22, 2020 at 4:16:54 PM UTC-4, J C wrote:
>
> I am using the collection not the role.  So it looks like this at the
> top.  Had to add the interpreter variable because Ansible kept using 
> Python
> 2
>
> ---
> - name: Interface Descrpitions
>   hosts: all
>   gather_facts: no
>   connection: network_cli
>   collections:
> - clay584.genie
>   vars:
> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>
> On Mon, Jun 22, 2020 at 2:44 PM Jason  wrote:
>
>> Thanks alot.
>>
>> I have been getting this error for the past few days when trying to
>> use genie:
>>
>> fatal: [SW1]: FAILED! => {
>> "msg": "template error while templating string: no filter named
>> 'clay584.genie.parse_genie'. String: {{ neighbors['stdout'][0] |
>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>> }
>>
>> *This is my playbook (what you sent but I needed to import the role
>> first):*
>> - hosts: uwioc-switches
>>   gather_facts: no
>>   tasks:
>> - name: Import role
>>   include_role:
>> name: clay584.parse_genie
>>
>> - name: Run show cdp neighbors
>>   ios_command:
>> commands:
>>   - show cdp neighbors
>>   register: neighbors
>>
>> # Using the Genie Filter Plugin from the Genie Parse Role
>> # Set pyats_neighbors as a dictionary
>> - name: Set fact with Genie
>> - name: Import role
>>   include_role:
>> name: clay584.parse_genie
>>
>> - name: Run show cdp neighbors
>>   ios_command:
>> commands:
>>   - show cdp neighbors
>>   register: neighbors
>>
>> # Using the Genie Filter Plugin from the Genie Parse Role
>> 

Re: [ansible-project] Ansible to connect to certain switchports on Cisco 2960

2020-06-23 Thread Jason
I added it. Now this shows:

fatal: [SW1]: FAILED! => {
*"msg": "parse_genie: Genie package is not installed. To install, run 
'pip install genie'."*
}

When I do pip or pip3 install genie, it says requirements already satisfied 
(as I already installed it). 

Just to show you what my directories look like:

[image: directory genie.JPG]

And under [defaults] in my ansible.cfg:

*collections_paths = /etc/ansible/collections/ansible_collections/* 

Tried putting a less specific and then a more specifc path to the 
collections folder also. (= /etc/ansible/collections, = 
/etc/ansible/collections/ansible_collections/clay584/genie)

Prior to this, I did a * ansible-galaxy collection install clay584.genie* 
to install the collection and it said this:
Installing 'clay584.genie:0.1.11' to 
'/root/.ansible/collections/ansible_collections/clay584/genie'

Did I do anything wrong?


On Tuesday, June 23, 2020 at 11:34:31 AM UTC-4, J C wrote:
>
> You need to add a new line under [defaults]
>
> collections_paths = /path/to/collections
>
> On Tue, Jun 23, 2020 at 10:29 AM Jason > 
> wrote:
>
>> No I have never used a collection before. So my ansible.cfg is currently 
>> to the default
>>
>> On Tuesday, June 23, 2020 at 11:22:11 AM UTC-4, J C wrote:
>>>
>>> Not sure it seems like it is looking for the filter.  Have you used a 
>>> collection before?  Is the collections_path defined in the ansible.cfg?
>>>
>>> On Mon, Jun 22, 2020 at 3:49 PM Jason  wrote:
>>>
 This error shows:
 fatal: [SW1]: FAILED! => {"msg": "template error while templating 
 string: no filter named 'clay584.genie.parse_genie'. String: {{ 
 neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp 
 neighbors', os='ios') }}"}


 This is the full playbook I am using:
 ---
 - name: Interface Descrpitions
   hosts: uwioc-switches
   gather_facts: no
   connection: network_cli
   collections:
 - clay584.genie
   vars:
 ansible_python_interpreter: "{{ ansible_playbook_python }}"
   tasks:
 - name: Run show cdp neighbors
   ios_command:
 commands:
   - show cdp neighbors
   register: neighbors
 # Using the Genie Filter Plugin from the Genie Parse Role
 # Set pyats_neighbors as a dictionary
 - name: Set fact with Genie Filter Plugin
   set_fact:
pyats_neighbors: "{{ neighbors['stdout'][0] | 
 clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"


 Tried changing vars to set_facts too, but didn't work. 

 On Monday, June 22, 2020 at 4:16:54 PM UTC-4, J C wrote:
>
> I am using the collection not the role.  So it looks like this at the 
> top.  Had to add the interpreter variable because Ansible kept using 
> Python 
> 2
>
> ---
> - name: Interface Descrpitions
>   hosts: all
>   gather_facts: no
>   connection: network_cli
>   collections:
> - clay584.genie
>   vars:
> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>
> On Mon, Jun 22, 2020 at 2:44 PM Jason  wrote:
>
>> Thanks alot. 
>>
>> I have been getting this error for the past few days when trying to 
>> use genie:
>>
>> fatal: [SW1]: FAILED! => {
>> "msg": "template error while templating string: no filter named 
>> 'clay584.genie.parse_genie'. String: {{ neighbors['stdout'][0] | 
>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>> }
>>
>> *This is my playbook (what you sent but I needed to import the role 
>> first):*
>> - hosts: uwioc-switches
>>   gather_facts: no
>>   tasks:
>> - name: Import role
>>   include_role:
>> name: clay584.parse_genie
>>
>> - name: Run show cdp neighbors
>>   ios_command:
>> commands:
>>   - show cdp neighbors
>>   register: neighbors
>>
>> # Using the Genie Filter Plugin from the Genie Parse Role
>> # Set pyats_neighbors as a dictionary
>> - name: Set fact with Genie
>> - name: Import role
>>   include_role:
>> name: clay584.parse_genie
>>
>> - name: Run show cdp neighbors
>>   ios_command:
>> commands:
>>   - show cdp neighbors
>>   register: neighbors
>>
>> # Using the Genie Filter Plugin from the Genie Parse Role
>> # Set pyats_neighbors as a dictionary
>> - name: Set fact with Genie Filter Plugin
>>   set_fact:
>> pyats_neighbors: "{{ neighbors['stdout'][0] | 
>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>>
>>
>> - name: Add interface description
>>   ios_interfaces:
>> config:
>>   - name: "{{ item.value.local_interface }}"
>> description: "{{ item.value.device_id

[ansible-project] Keep-alive connections for httpapi plugins

2020-06-23 Thread Alexandru Obretin
 Hello,

I am working on a custom HTTP connection plugin and some related modules in 
order to access a proprietary REST API. For this purpose, I have to provide 
capabilities for basic create/update/delete operations on different 
entities. 

While developing the plugin, I have noticed the standard httpapi 
implimentation is relying on urllib_request.urlopen inside the open() 
method from module_utils/urls.py.

Further, the AbstractHTTPHandler provided by the urllib_request has the 
following limitation:

# TODO(jhylton): Should this be redesigned to handle
# persistent connections?

# We want to make an HTTP/1.1 request, but the addinfourl
# class isn't prepared to deal with a persistent connection.
# It will try to read all remaining data from the socket,
# which will block while the server waits for the next request.
# So make sure the connection gets closed after the (only)
# request.
headers["Connection"] = "close"

Therefore, I cannot create 'keep-alive' connections which further 
interferes with PUT or POST requests that have a payload which is send to 
the server in a separate request - check implementation in 
/usr/lib/python3/http/client.py, _send_output() method. 

Under these circumstances, is there any way to use urllib3 in Ansible for 
http connections? Or any workaround to keep the connection alive until the 
payload is send to the server?

Thank you for your time!

Regards,
Alex

-- 
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/6de169c5-ce43-4e57-8f34-3818d7de9191n%40googlegroups.com.


[ansible-project] Question on using the Ansible API

2020-06-23 Thread tterr...@gmail.com
I have a big ansible project where I have separated my files into 
playbooks, vars files, an inventory folder and roles. These files make 
extensive use of jinja templates.

For my use case, I need to be able to access the variables in these files 
outside ansible. So far, I have included `copy` tasks to dump the variable 
I need to templated out vars files. Then, in my app I read those with the 
python `yaml` module without issue since they are free of jinja templates. 
The variables I am interested in are the variables in the `vars` section of 
a playbook as well as those in `vars_files`. Such variables, get merged 
with role defaults.

I am now trying to remove those `copy` tasks and instead use the Ansible 
API to get the final value for the variables. This will also have the 
benefit of fully respecting the precedence rules baked into Ansible. So 
far, this is what I have come up with.

```
#!/usr/bin/env python 

import code
import os
import readline 
import rlcompleter 

os.environ["ANSIBLE_CONFIG"] = "ansible/ansible.cfg" 
 
import ansible.constants as C 
from ansible.inventory.manager
import InventoryManager
from ansible.parsing.dataloader import DataLoader 
from ansible.vars.manager import VariableManager 
from ansible.template import Templar

from ansible.playbook import Playbook 

loader = DataLoader() 
inventory = InventoryManager( loader=loader, 
sources=["data/worlds/active/inventory/configs"] ) 
variable_manager = VariableManager(loader=loader, inventory=inventory) 

p = Playbook.load( "ansible/plays/instances/main.yml", loader=loader, 
variable_manager=variable_manager) 

readline.parse_and_bind("tab: complete") 
code.InteractiveConsole(locals=globals()).interact() 
```

I don't know how to proceed. I am supposed to actually run the tasks in the 
playbook to manage to get the variables? Can I somehow achieve what I want 
with the Ansible API without running any task? I don't care about 
`set_fact` or dynamic creation/alteration of the variables.

-- 
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/130c4ab9-028f-4c20-8802-04a8691dcc2fn%40googlegroups.com.


Re: [ansible-project] Ansible to connect to certain switchports on Cisco 2960

2020-06-23 Thread J C
You need to add a new line under [defaults]

collections_paths = /path/to/collections

On Tue, Jun 23, 2020 at 10:29 AM Jason  wrote:

> No I have never used a collection before. So my ansible.cfg is currently
> to the default
>
> On Tuesday, June 23, 2020 at 11:22:11 AM UTC-4, J C wrote:
>>
>> Not sure it seems like it is looking for the filter.  Have you used a
>> collection before?  Is the collections_path defined in the ansible.cfg?
>>
>> On Mon, Jun 22, 2020 at 3:49 PM Jason  wrote:
>>
>>> This error shows:
>>> fatal: [SW1]: FAILED! => {"msg": "template error while templating
>>> string: no filter named 'clay584.genie.parse_genie'. String: {{
>>> neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp
>>> neighbors', os='ios') }}"}
>>>
>>>
>>> This is the full playbook I am using:
>>> ---
>>> - name: Interface Descrpitions
>>>   hosts: uwioc-switches
>>>   gather_facts: no
>>>   connection: network_cli
>>>   collections:
>>> - clay584.genie
>>>   vars:
>>> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>>>   tasks:
>>> - name: Run show cdp neighbors
>>>   ios_command:
>>> commands:
>>>   - show cdp neighbors
>>>   register: neighbors
>>> # Using the Genie Filter Plugin from the Genie Parse Role
>>> # Set pyats_neighbors as a dictionary
>>> - name: Set fact with Genie Filter Plugin
>>>   set_fact:
>>>pyats_neighbors: "{{ neighbors['stdout'][0] |
>>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>>>
>>>
>>> Tried changing vars to set_facts too, but didn't work.
>>>
>>> On Monday, June 22, 2020 at 4:16:54 PM UTC-4, J C wrote:

 I am using the collection not the role.  So it looks like this at the
 top.  Had to add the interpreter variable because Ansible kept using Python
 2

 ---
 - name: Interface Descrpitions
   hosts: all
   gather_facts: no
   connection: network_cli
   collections:
 - clay584.genie
   vars:
 ansible_python_interpreter: "{{ ansible_playbook_python }}"

 On Mon, Jun 22, 2020 at 2:44 PM Jason  wrote:

> Thanks alot.
>
> I have been getting this error for the past few days when trying to
> use genie:
>
> fatal: [SW1]: FAILED! => {
> "msg": "template error while templating string: no filter named
> 'clay584.genie.parse_genie'. String: {{ neighbors['stdout'][0] |
> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
> }
>
> *This is my playbook (what you sent but I needed to import the role
> first):*
> - hosts: uwioc-switches
>   gather_facts: no
>   tasks:
> - name: Import role
>   include_role:
> name: clay584.parse_genie
>
> - name: Run show cdp neighbors
>   ios_command:
> commands:
>   - show cdp neighbors
>   register: neighbors
>
> # Using the Genie Filter Plugin from the Genie Parse Role
> # Set pyats_neighbors as a dictionary
> - name: Set fact with Genie
> - name: Import role
>   include_role:
> name: clay584.parse_genie
>
> - name: Run show cdp neighbors
>   ios_command:
> commands:
>   - show cdp neighbors
>   register: neighbors
>
> # Using the Genie Filter Plugin from the Genie Parse Role
> # Set pyats_neighbors as a dictionary
> - name: Set fact with Genie Filter Plugin
>   set_fact:
> pyats_neighbors: "{{ neighbors['stdout'][0] |
> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>
>
> - name: Add interface description
>   ios_interfaces:
> config:
>   - name: "{{ item.value.local_interface }}"
> description: "{{ item.value.device_id }} - {{
> item.value.port_id }}"
> state: merged
>   loop: "{{ q('dict', pyats_neighbors.index) }}"
>   when: item.value.port_id is "AIR-AP280"
>
> My python version is 3.6.8 and Ansible is 2.9.9
>
> I followed this guide to install the necessary libraries:
>
> https://developer.cisco.com/codeexchange/github/repo/clay584/parse_genie/
>
>
> The error still persists.  Also posted the issue on GitHub. Not sure
> if it is bug in the parsing library.
>
> Any assistance would greatly be appreciated.
>
> Thanks.
>
> On Monday, June 22, 2020 at 9:07:18 AM UTC-4, J C wrote:
>>
>> Something like that I suppose.
>>
>>
>> #Sets a varaiable for cdp neighbor detail
>>   - name: Run show cdp neighbors command
>> ios_command:
>>   commands:
>> - show cdp neighbors detail
>> register: neighbors
>>
>> # Using the Genie Filter Plugin from the Genie Parse Role
>> # Set pyats_neighbors as a dictionary
>>   - name: Set fact with Gen

Re: [ansible-project] Ansible to connect to certain switchports on Cisco 2960

2020-06-23 Thread Jason
No I have never used a collection before. So my ansible.cfg is currently to 
the default

On Tuesday, June 23, 2020 at 11:22:11 AM UTC-4, J C wrote:
>
> Not sure it seems like it is looking for the filter.  Have you used a 
> collection before?  Is the collections_path defined in the ansible.cfg?
>
> On Mon, Jun 22, 2020 at 3:49 PM Jason > 
> wrote:
>
>> This error shows:
>> fatal: [SW1]: FAILED! => {"msg": "template error while templating string: 
>> no filter named 'clay584.genie.parse_genie'. String: {{ 
>> neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp 
>> neighbors', os='ios') }}"}
>>
>>
>> This is the full playbook I am using:
>> ---
>> - name: Interface Descrpitions
>>   hosts: uwioc-switches
>>   gather_facts: no
>>   connection: network_cli
>>   collections:
>> - clay584.genie
>>   vars:
>> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>>   tasks:
>> - name: Run show cdp neighbors
>>   ios_command:
>> commands:
>>   - show cdp neighbors
>>   register: neighbors
>> # Using the Genie Filter Plugin from the Genie Parse Role
>> # Set pyats_neighbors as a dictionary
>> - name: Set fact with Genie Filter Plugin
>>   set_fact:
>>pyats_neighbors: "{{ neighbors['stdout'][0] | 
>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>>
>>
>> Tried changing vars to set_facts too, but didn't work. 
>>
>> On Monday, June 22, 2020 at 4:16:54 PM UTC-4, J C wrote:
>>>
>>> I am using the collection not the role.  So it looks like this at the 
>>> top.  Had to add the interpreter variable because Ansible kept using Python 
>>> 2
>>>
>>> ---
>>> - name: Interface Descrpitions
>>>   hosts: all
>>>   gather_facts: no
>>>   connection: network_cli
>>>   collections:
>>> - clay584.genie
>>>   vars:
>>> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>>>
>>> On Mon, Jun 22, 2020 at 2:44 PM Jason  wrote:
>>>
 Thanks alot. 

 I have been getting this error for the past few days when trying to use 
 genie:

 fatal: [SW1]: FAILED! => {
 "msg": "template error while templating string: no filter named 
 'clay584.genie.parse_genie'. String: {{ neighbors['stdout'][0] | 
 clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
 }

 *This is my playbook (what you sent but I needed to import the role 
 first):*
 - hosts: uwioc-switches
   gather_facts: no
   tasks:
 - name: Import role
   include_role:
 name: clay584.parse_genie

 - name: Run show cdp neighbors
   ios_command:
 commands:
   - show cdp neighbors
   register: neighbors

 # Using the Genie Filter Plugin from the Genie Parse Role
 # Set pyats_neighbors as a dictionary
 - name: Set fact with Genie
 - name: Import role
   include_role:
 name: clay584.parse_genie

 - name: Run show cdp neighbors
   ios_command:
 commands:
   - show cdp neighbors
   register: neighbors

 # Using the Genie Filter Plugin from the Genie Parse Role
 # Set pyats_neighbors as a dictionary
 - name: Set fact with Genie Filter Plugin
   set_fact:
 pyats_neighbors: "{{ neighbors['stdout'][0] | 
 clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"


 - name: Add interface description
   ios_interfaces:
 config:
   - name: "{{ item.value.local_interface }}"
 description: "{{ item.value.device_id }} - {{ 
 item.value.port_id }}"
 state: merged
   loop: "{{ q('dict', pyats_neighbors.index) }}"
   when: item.value.port_id is "AIR-AP280"

 My python version is 3.6.8 and Ansible is 2.9.9

 I followed this guide to install the necessary libraries:

 https://developer.cisco.com/codeexchange/github/repo/clay584/parse_genie/
  

 The error still persists.  Also posted the issue on GitHub. Not sure if 
 it is bug in the parsing library. 

 Any assistance would greatly be appreciated. 

 Thanks.

 On Monday, June 22, 2020 at 9:07:18 AM UTC-4, J C wrote:
>
> Something like that I suppose. 
>
>
> #Sets a varaiable for cdp neighbor detail
>   - name: Run show cdp neighbors command
> ios_command:
>   commands:
> - show cdp neighbors detail
> register: neighbors
>
> # Using the Genie Filter Plugin from the Genie Parse Role
> # Set pyats_neighbors as a dictionary
>   - name: Set fact with Genie Filter Plugin
> set_fact:
>   pyats_neighbors: "
> {{ neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp 
> neighbors detail', os='ios') }}
> "
>   - name: Add interface desription
> ios_interfaces:

Re: [ansible-project] Ansible to connect to certain switchports on Cisco 2960

2020-06-23 Thread J C
Not sure it seems like it is looking for the filter.  Have you used a
collection before?  Is the collections_path defined in the ansible.cfg?

On Mon, Jun 22, 2020 at 3:49 PM Jason  wrote:

> This error shows:
> fatal: [SW1]: FAILED! => {"msg": "template error while templating string:
> no filter named 'clay584.genie.parse_genie'. String: {{
> neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp
> neighbors', os='ios') }}"}
>
>
> This is the full playbook I am using:
> ---
> - name: Interface Descrpitions
>   hosts: uwioc-switches
>   gather_facts: no
>   connection: network_cli
>   collections:
> - clay584.genie
>   vars:
> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>   tasks:
> - name: Run show cdp neighbors
>   ios_command:
> commands:
>   - show cdp neighbors
>   register: neighbors
> # Using the Genie Filter Plugin from the Genie Parse Role
> # Set pyats_neighbors as a dictionary
> - name: Set fact with Genie Filter Plugin
>   set_fact:
>pyats_neighbors: "{{ neighbors['stdout'][0] |
> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>
>
> Tried changing vars to set_facts too, but didn't work.
>
> On Monday, June 22, 2020 at 4:16:54 PM UTC-4, J C wrote:
>>
>> I am using the collection not the role.  So it looks like this at the
>> top.  Had to add the interpreter variable because Ansible kept using Python
>> 2
>>
>> ---
>> - name: Interface Descrpitions
>>   hosts: all
>>   gather_facts: no
>>   connection: network_cli
>>   collections:
>> - clay584.genie
>>   vars:
>> ansible_python_interpreter: "{{ ansible_playbook_python }}"
>>
>> On Mon, Jun 22, 2020 at 2:44 PM Jason  wrote:
>>
>>> Thanks alot.
>>>
>>> I have been getting this error for the past few days when trying to use
>>> genie:
>>>
>>> fatal: [SW1]: FAILED! => {
>>> "msg": "template error while templating string: no filter named
>>> 'clay584.genie.parse_genie'. String: {{ neighbors['stdout'][0] |
>>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>>> }
>>>
>>> *This is my playbook (what you sent but I needed to import the role
>>> first):*
>>> - hosts: uwioc-switches
>>>   gather_facts: no
>>>   tasks:
>>> - name: Import role
>>>   include_role:
>>> name: clay584.parse_genie
>>>
>>> - name: Run show cdp neighbors
>>>   ios_command:
>>> commands:
>>>   - show cdp neighbors
>>>   register: neighbors
>>>
>>> # Using the Genie Filter Plugin from the Genie Parse Role
>>> # Set pyats_neighbors as a dictionary
>>> - name: Set fact with Genie
>>> - name: Import role
>>>   include_role:
>>> name: clay584.parse_genie
>>>
>>> - name: Run show cdp neighbors
>>>   ios_command:
>>> commands:
>>>   - show cdp neighbors
>>>   register: neighbors
>>>
>>> # Using the Genie Filter Plugin from the Genie Parse Role
>>> # Set pyats_neighbors as a dictionary
>>> - name: Set fact with Genie Filter Plugin
>>>   set_fact:
>>> pyats_neighbors: "{{ neighbors['stdout'][0] |
>>> clay584.genie.parse_genie(command='show cdp neighbors', os='ios') }}"
>>>
>>>
>>> - name: Add interface description
>>>   ios_interfaces:
>>> config:
>>>   - name: "{{ item.value.local_interface }}"
>>> description: "{{ item.value.device_id }} - {{
>>> item.value.port_id }}"
>>> state: merged
>>>   loop: "{{ q('dict', pyats_neighbors.index) }}"
>>>   when: item.value.port_id is "AIR-AP280"
>>>
>>> My python version is 3.6.8 and Ansible is 2.9.9
>>>
>>> I followed this guide to install the necessary libraries:
>>> https://developer.cisco.com/codeexchange/github/repo/clay584/parse_genie/
>>>
>>>
>>> The error still persists.  Also posted the issue on GitHub. Not sure if
>>> it is bug in the parsing library.
>>>
>>> Any assistance would greatly be appreciated.
>>>
>>> Thanks.
>>>
>>> On Monday, June 22, 2020 at 9:07:18 AM UTC-4, J C wrote:

 Something like that I suppose.


 #Sets a varaiable for cdp neighbor detail
   - name: Run show cdp neighbors command
 ios_command:
   commands:
 - show cdp neighbors detail
 register: neighbors

 # Using the Genie Filter Plugin from the Genie Parse Role
 # Set pyats_neighbors as a dictionary
   - name: Set fact with Genie Filter Plugin
 set_fact:
   pyats_neighbors: "
 {{ neighbors['stdout'][0] | clay584.genie.parse_genie(command='show cdp 
 neighbors detail', os='ios') }}
 "
   - name: Add interface desription
 ios_interfaces:
   config:
 - name: "{{ item.value.local_interface }}"
   description: "
 {{ item.value.device_id }} - {{ item.value.port_id }}"
   state: merged
 loop: "{{ q('dict', pyats_neighbors.index) }}"
 when: item.value.port_id is "AIR-AP280"

 On Sat, Jun 20, 2020 at 1:

[ansible-project] Re: keycloak modules support or samples

2020-06-23 Thread Antoine Valley
I had a look at the source code. Unfortunately it seams that this module 
provide only few features and does not handle sub groups :
https://github.com/ansible/ansible/blob/stable-2.8/lib/ansible/modules/identity/keycloak/keycloak_group.py

Le mercredi 19 février 2020 10:46:38 UTC+1, Torsten Reinhard a écrit :
>
> Hi community, 
>
> I started to provision a KeyCloak instance (based on the Docker image) 
> with the available modules 
>
> keycloak_client
> keycloak_group
>
> I could´nt find any thread regarding these modules - so my question is if 
> there´s any experience out there?
> For example I´m interested in 
> - how to create Groups with subGroups, 
> - how to manage roles
> - how to manage users
> - 
>
> Thanx for any support or links to some samples, 
>
> Torsten
>
>

-- 
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/9eff6491-692d-41a7-81af-b9ef385459c2o%40googlegroups.com.


[ansible-project] CentOS repository patching

2020-06-23 Thread Snehal Mehar
Hello,

I need help with setting up Centos client-server with centos repository 
URL. It should add a repository URL to the client-server and patch to the 
next available version identifying the existing os version. 

I have created a role but the patching task gets failed because of no 
mirrors found. Any help here would be appreciated. 

===
main.yml code:

- name: Perform Patch
  include_tasks: centos.yml
  when: ansible_distribution == "CentOS"

- name: Perform Patch
  include_tasks: redhat.yml
  when: ansible_distribution == "RedHat"

- name: Perform Patch
  include_tasks: ubuntu.yml
  when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian"

- name: Perform Patch
  include_tasks: suse.yml
  when: ansible_distribution == "openSUSE Leap"

==
centos.yml code: 

  - name: Enable centos repo in yum

template:

  src: centos.repo.j2

  dest: /etc/yum.repos.d/CentOS-Base.repo


  - name: Check Dist Version

shell: cat /etc/redhat-release

register: response



  - name: Contents of the register

debug: msg="{{ response.stdout }}"



  - name: Distribution

debug: msg="{{ ansible_distribution }}"



  - name: Distribution version

debug: msg="{{ ansible_distribution_version}}"



  - name: Distribution major version

debug: msg="{{ ansible_distribution_major_version }}"



  - name: Upgrade all installed packages for CentOS

yum:

  name: "*"

  state: latest

when: ansible_distribution == "CentOS"
=

centos.repo.j2 file in template:

[base]
name = CentOS
baseurl = http://mirror.centos.org/{{ ansible_distribution | lower }}/{{ 
ansible_distribution_major_version }}/updates/{{ ansible_architecture }}
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
gpgcheck = 1
enabled = 1

==

Error:

TASK [template.patching : Upgrade all installed packages for CentOS] 
**
fatal: [waldevprodcen02]: FAILED! => {"changed": true, "changes": 
{"installed": [], "updated": [["freerdp-libs", "2.0.0-4.rc4.el7_8.x86_64 
from base"] Not found\nError: Package: vinagre-3.22.0-9.el7.x86_64 
(@anaconda)\n   Requires: libfreerdp-utils.so.1.0()(64bit)\n
   Removing: freerdp-libs-1.0.2-15.el7.x86_64 (@anaconda)\n  
 libfreerdp-utils.so.1.0()(64bit)\n   Updated By: 
freerdp-libs-2.0.0-4.rc4.el7_8.x86_64 (base)\n   Not 
found\nError: Package: mesa-libxatracker-18.3.4-7.el7_8.1.x86_64 (base)\n  
 Requires: libLLVM-7-rhel.so(LLVM_7)(64bit)\nError: Package: 
1:java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64 (base)\n  
 Requires: nss-softokn(x86-64) >= 3.44.0\n   Installed: 
nss-softokn-3.36.0-5.el7_5.x86_64 (@anaconda)\n  
 nss-softokn(x86-64) = 3.36.0-5.el7_5\nError: Package: 
vinagre-3.22.0-9.el7.x86_64 (@anaconda)\n   Requires: 
libfreerdp-rail.so.1.0()(64bit)\n   Removing: 
freerdp-libs-1.0.2-15.el7.x86_64 (@anaconda)\n  
 libfreerdp-rail.so.1.0()(64bit)\n   Updated By: 
freerdp-libs-2.0.0-4.rc4.el7_8.x86_64 (base)\n   Not 
found\nError: Package: 12:dhclient-4.2.5-68.el7.centos.1.x86_64 
(@anaconda)\n   Requires: libisc-export.so.95()(64bit)\n  
 Removing: 32:bind-libs-lite-9.9.4-72.el7.x86_64 (@anaconda)\n  
 libisc-export.so.95()(64bit)\n   Updated By: 
32:bind-libs-lite-9.11.4-16.P2.el7_8.6.x86_64 (base)\n   Not 
found\nError:

PLAY RECAP 

waldevprodcen02: ok=8changed=1unreachable=0
failed=1skipped=0rescued=0ignored=0



Centos URL:

http://mirror.centos.org/centos/7/


Thanks,
Snehal



































-- 
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/181f383d-7601-405a-9f20-d740411b55a3o%40googlegroups.com.


Re: [ansible-project] fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance creation failed

2020-06-23 Thread Avinash Jadhav
https://www.mindbowser.com/how-to-create-ec2-instances-using-ansible/

please jump on the above link

On Tue, 23 Jun 2020 at 15:46, Abhijeet Kasurde  wrote:

> Hi Avinash,
>
> Mujeeb already tried these things. Error is due to ARM AMI not running on
> any region. I don't have an account to test this. Can you please help?
>
> Mujeeb, please specify all details like AMI and region details and console
> log.
>
> On Tue, Jun 23, 2020 at 3:41 PM Avinash Jadhav 
> wrote:
>
>> Hi Mujeeb,
>> Please follow the below step
>>
>> Once you are done with the AWS account and the User creation, you can
>> move forward and install the required things.
>>
>>1. Ansible:
>>   1. Install Ansible on a RHEL/CentOS Linux based system
>>  1. *$ sudo yum install Ansible*
>>   2. Install Ansible on a Debian/Ubuntu Linux based system
>>  1. *$ sudo apt-get install software-properties-common*
>>  2. *$ sudo apt-add-repository ppa:Ansible/Ansible*
>>  3. *$ sudo apt-get update*
>>  4. *$ sudo apt-get install Ansible*
>>   3. Install Ansible using pip
>>  1. *$ sudo pip install Ansible*
>>  2. *Once installed you can verify by Ansible –version this
>>  command.*
>>   2. Python:
>>   1. $ sudo apt-get update
>>   2. $ sudo apt-get install python3.6
>>   3. You can follow this link
>>    for more
>>   details.
>>3. Boto: (Boto is a Python package which provides an interface to
>>AWS.)
>>   1. First, install pip
>>  1. *$ sudo apt install python3-pip or*
>>  2. *$ yum install python-pip*
>>   2. Now install boto
>>  1. *$ pip install boto*
>>
>> Now, we are done with the package installation, we can move ahead and
>> start writing our Ansible playbook.
>> Note: There are multiple ways you can install the above packages. I have
>> added the ones that I followed but you can install as per your knowledge.
>> Now open a terminal and create a file with the extension .yml or .ymal,
>> add below script and save it.
>>
>> # Basic provisioning example
>> - name: Ansible test
>> hosts: localhost
>> tasks:
>> - name: launching AWS instance using Ansible
>> ec2:
>> key_name: aws_instance_Ansible
>> instance_type: t2.micro
>> image: ami-0dacb0c129b49f529
>> region: us-east-2
>> wait: yes
>> group: Ansible
>> count: 1
>> vpc_subnet_id: default
>> assign_public_ip: yes
>> aws_access_key: ***
>> Aws_secret_key: ***
>>
>>
>> On Tue, 23 Jun 2020 at 15:37, Mujeeb k.s  wrote:
>>
>>> Hi
>>>
>>> I am trying to create EC2 in using play book, but i am unable to create
>>> instance
>>> I am getting below error
>>>
>>> Please help me, how can i fix this issue
>>>
>>>
>>> [root@jenkinansible ansible]# ansible-playbook ec2.yml
>>>
>>> PLAY [creating ec2 instance]
>>> 
>>>
>>> TASK [Gathering Facts]
>>> **
>>> ok: [localhost]
>>>
>>> TASK [creating ec2 instance]
>>> 
>>> fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance
>>> creation failed => Unsupported: The requested configuration is currently
>>> not supported. Please check the documentation for supported
>>> configurations."}
>>>
>>> PLAY RECAP
>>> **
>>> localhost  : ok=1changed=0unreachable=0
>>> failed=1skipped=0rescued=0ignored=0
>>>
>>> [root@jenkinansible 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/509b3dbe-e01c-4a52-833d-65eb0c5dedb8o%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/ansibl

Re: [ansible-project] fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance creation failed

2020-06-23 Thread Abhijeet Kasurde
Hi Avinash,

Mujeeb already tried these things. Error is due to ARM AMI not running on
any region. I don't have an account to test this. Can you please help?

Mujeeb, please specify all details like AMI and region details and console
log.

On Tue, Jun 23, 2020 at 3:41 PM Avinash Jadhav 
wrote:

> Hi Mujeeb,
> Please follow the below step
>
> Once you are done with the AWS account and the User creation, you can move
> forward and install the required things.
>
>1. Ansible:
>   1. Install Ansible on a RHEL/CentOS Linux based system
>  1. *$ sudo yum install Ansible*
>   2. Install Ansible on a Debian/Ubuntu Linux based system
>  1. *$ sudo apt-get install software-properties-common*
>  2. *$ sudo apt-add-repository ppa:Ansible/Ansible*
>  3. *$ sudo apt-get update*
>  4. *$ sudo apt-get install Ansible*
>   3. Install Ansible using pip
>  1. *$ sudo pip install Ansible*
>  2. *Once installed you can verify by Ansible –version this
>  command.*
>   2. Python:
>   1. $ sudo apt-get update
>   2. $ sudo apt-get install python3.6
>   3. You can follow this link
>    for more
>   details.
>3. Boto: (Boto is a Python package which provides an interface to AWS.)
>   1. First, install pip
>  1. *$ sudo apt install python3-pip or*
>  2. *$ yum install python-pip*
>   2. Now install boto
>  1. *$ pip install boto*
>
> Now, we are done with the package installation, we can move ahead and
> start writing our Ansible playbook.
> Note: There are multiple ways you can install the above packages. I have
> added the ones that I followed but you can install as per your knowledge.
> Now open a terminal and create a file with the extension .yml or .ymal,
> add below script and save it.
>
> # Basic provisioning example
> - name: Ansible test
> hosts: localhost
> tasks:
> - name: launching AWS instance using Ansible
> ec2:
> key_name: aws_instance_Ansible
> instance_type: t2.micro
> image: ami-0dacb0c129b49f529
> region: us-east-2
> wait: yes
> group: Ansible
> count: 1
> vpc_subnet_id: default
> assign_public_ip: yes
> aws_access_key: ***
> Aws_secret_key: ***
>
>
> On Tue, 23 Jun 2020 at 15:37, Mujeeb k.s  wrote:
>
>> Hi
>>
>> I am trying to create EC2 in using play book, but i am unable to create
>> instance
>> I am getting below error
>>
>> Please help me, how can i fix this issue
>>
>>
>> [root@jenkinansible ansible]# ansible-playbook ec2.yml
>>
>> PLAY [creating ec2 instance]
>> 
>>
>> TASK [Gathering Facts]
>> **
>> ok: [localhost]
>>
>> TASK [creating ec2 instance]
>> 
>> fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance
>> creation failed => Unsupported: The requested configuration is currently
>> not supported. Please check the documentation for supported
>> configurations."}
>>
>> PLAY RECAP
>> **
>> localhost  : ok=1changed=0unreachable=0
>> failed=1skipped=0rescued=0ignored=0
>>
>> [root@jenkinansible 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/509b3dbe-e01c-4a52-833d-65eb0c5dedb8o%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/CABAvFDOpaNCLqh%3Dc-mszTXuifQ%2B3R%2BYSZtwF9PQn%3DMh0Xf0aAg%40mail.gmail.com
> 
> .
>


-- 
Thanks,
Abhijeet Kasurde

Re: [ansible-project] fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance creation failed

2020-06-23 Thread Avinash Jadhav
Hi Mujeeb,
Please follow the below step

Once you are done with the AWS account and the User creation, you can move
forward and install the required things.

   1. Ansible:
  1. Install Ansible on a RHEL/CentOS Linux based system
 1. *$ sudo yum install Ansible*
  2. Install Ansible on a Debian/Ubuntu Linux based system
 1. *$ sudo apt-get install software-properties-common*
 2. *$ sudo apt-add-repository ppa:Ansible/Ansible*
 3. *$ sudo apt-get update*
 4. *$ sudo apt-get install Ansible*
  3. Install Ansible using pip
 1. *$ sudo pip install Ansible*
 2. *Once installed you can verify by Ansible –version this
 command.*
  2. Python:
  1. $ sudo apt-get update
  2. $ sudo apt-get install python3.6
  3. You can follow this link
   for more
  details.
   3. Boto: (Boto is a Python package which provides an interface to AWS.)
  1. First, install pip
 1. *$ sudo apt install python3-pip or*
 2. *$ yum install python-pip*
  2. Now install boto
 1. *$ pip install boto*

Now, we are done with the package installation, we can move ahead and start
writing our Ansible playbook.
Note: There are multiple ways you can install the above packages. I have
added the ones that I followed but you can install as per your knowledge.
Now open a terminal and create a file with the extension .yml or .ymal, add
below script and save it.

# Basic provisioning example
- name: Ansible test
hosts: localhost
tasks:
- name: launching AWS instance using Ansible
ec2:
key_name: aws_instance_Ansible
instance_type: t2.micro
image: ami-0dacb0c129b49f529
region: us-east-2
wait: yes
group: Ansible
count: 1
vpc_subnet_id: default
assign_public_ip: yes
aws_access_key: ***
Aws_secret_key: ***


On Tue, 23 Jun 2020 at 15:37, Mujeeb k.s  wrote:

> Hi
>
> I am trying to create EC2 in using play book, but i am unable to create
> instance
> I am getting below error
>
> Please help me, how can i fix this issue
>
>
> [root@jenkinansible ansible]# ansible-playbook ec2.yml
>
> PLAY [creating ec2 instance]
> 
>
> TASK [Gathering Facts]
> **
> ok: [localhost]
>
> TASK [creating ec2 instance]
> 
> fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance
> creation failed => Unsupported: The requested configuration is currently
> not supported. Please check the documentation for supported
> configurations."}
>
> PLAY RECAP
> **
> localhost  : ok=1changed=0unreachable=0
> failed=1skipped=0rescued=0ignored=0
>
> [root@jenkinansible 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/509b3dbe-e01c-4a52-833d-65eb0c5dedb8o%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/CABAvFDOpaNCLqh%3Dc-mszTXuifQ%2B3R%2BYSZtwF9PQn%3DMh0Xf0aAg%40mail.gmail.com.


[ansible-project] fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance creation failed

2020-06-23 Thread Mujeeb k.s
Hi

I am trying to create EC2 in using play book, but i am unable to create 
instance 
I am getting below error

Please help me, how can i fix this issue


[root@jenkinansible ansible]# ansible-playbook ec2.yml

PLAY [creating ec2 instance] 


TASK [Gathering Facts] 
**
ok: [localhost]

TASK [creating ec2 instance] 

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Instance creation 
failed => Unsupported: The requested configuration is currently not 
supported. Please check the documentation for supported configurations."}

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

[root@jenkinansible 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/509b3dbe-e01c-4a52-833d-65eb0c5dedb8o%40googlegroups.com.