[ansible-project] Re: Execute the ipaddr filter after installation

2019-05-14 Thread Jack Ivanov
No, this is not the case, I'm running the playbook on localhost and 
deploying to localhost. The problem is that python is not reloading the 
cache for each task.

On Wednesday, May 15, 2019 at 5:53:20 AM UTC+2, David Rojas wrote:
>
> You are installing it on the target device but it needs to be installed on 
> the absolve engine node basically where you are running your playbook from. 
> Just do a pip install for that module once then rerun your playbook but 
> take out that pip install not needed on your target 

-- 
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/b096b3c1-ed8c-45d6-89c9-6c69eb52a6ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Execute the ipaddr filter after installation

2019-05-14 Thread David Rojas
You are installing it on the target device but it needs to be installed on the 
absolve engine node basically where you are running your playbook from. Just do 
a pip install for that module once then rerun your playbook but take out that 
pip install not needed on your target 

-- 
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/22155c51-57dd-436c-ae5e-52e80f61ab63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Change current directory

2019-05-14 Thread James Cassell



On Tue, May 14, 2019, at 8:20 PM, Kevin Kwon wrote:
> 
> 
> Hi..
> 
> I want to change the current directory in remote host by Ansible.
> so, i have created the playbook like below. but, it is not working 
> correctly.
> 

What problem are you actually trying to solve? Maybe try `args: chdir=/mydir`

V/r,
James Cassell


> would you please let me know how can i do change the current directory in 
> the remote host?
> 
> Kevin
> 
> 
> 
> ===
> 
> ---
> - name: Testing to change current direcotry
>   hosts: Ansible-01
>   tasks:
>   - name: confirm current Directory in the switch
> become: yes
> become_method: sudo
> command: 'pwd'
> register: exec_result
>   - debug: var=exec_result.stdout_lines
> 
>   - name: Go to "/tmp" Directory in the switch
> become: yes
> become_method: sudo
> command: ' cd /tmp '
> 
>   - name: confirm current Directory in the switch
> become: yes
> become_method: sudo
> command: 'pwd'
> register: exec_result
>   - debug: var=exec_result.stdout_lines
> 
> 
> ==
> 
> admin@ubuntu-Ansible:~$ ansible-playbook Change-dir.yml
> 
> PLAY [Testing to change current direcotry] 
> ***
> 
> TASK [Gathering Facts] 
> ***
> ok: [Ansible-01]
> 
> TASK [confirm current Directory in the switch] 
> ***
> changed: [Ansible-01]
> 
> TASK [debug] 
> *
> ok: [Ansible-01] => {
> "exec_result.stdout_lines": [
> *"/home/admin"*
> ]
> }
> 
> TASK [Go to "/tmp" Directory in the switch] 
> 
> fatal: [Ansible-01]: FAILED! => {"changed": false, "cmd": "cd /tmp", 
> "msg": 
> "[Errno 2] No such file or directory", "rc": 2}
> to retry, use: --limit @/home/admin/Change-dir.retry
> 
> PLAY RECAP 
> ***
> Ansible-01   : ok=3changed=1unreachable=0failed=1
> 
> admin@ubuntu-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/1557879876.1209629.1669197072.58A7B777%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Change current directory

2019-05-14 Thread Kevin Kwon


Hi..

I want to change the current directory in remote host by Ansible.
so, i have created the playbook like below. but, it is not working 
correctly.

would you please let me know how can i do change the current directory in 
the remote host?

Kevin



===

---
- name: Testing to change current direcotry
  hosts: Ansible-01
  tasks:
  - name: confirm current Directory in the switch
become: yes
become_method: sudo
command: 'pwd'
register: exec_result
  - debug: var=exec_result.stdout_lines

  - name: Go to "/tmp" Directory in the switch
become: yes
become_method: sudo
command: ' cd /tmp '

  - name: confirm current Directory in the switch
become: yes
become_method: sudo
command: 'pwd'
register: exec_result
  - debug: var=exec_result.stdout_lines


==

admin@ubuntu-Ansible:~$ ansible-playbook Change-dir.yml

PLAY [Testing to change current direcotry] 
***

TASK [Gathering Facts] 
***
ok: [Ansible-01]

TASK [confirm current Directory in the switch] 
***
changed: [Ansible-01]

TASK [debug] 
*
ok: [Ansible-01] => {
"exec_result.stdout_lines": [
*"/home/admin"*
]
}

TASK [Go to "/tmp" Directory in the switch] 

fatal: [Ansible-01]: FAILED! => {"changed": false, "cmd": "cd /tmp", "msg": 
"[Errno 2] No such file or directory", "rc": 2}
to retry, use: --limit @/home/admin/Change-dir.retry

PLAY RECAP 
***
Ansible-01   : ok=3changed=1unreachable=0failed=1

admin@ubuntu-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/4c6c90a0-445a-4e1e-ae6d-6d2e23f23369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Rollback in Ansible ?

2019-05-14 Thread James Cassell



On Tue, May 14, 2019, at 12:08 PM, Ryad karkar wrote:
> Hey,
> 
> It is really very interesting this section rescue but if in my block I 
> execute for example a script sql which does a lot of actions and that there 
> is an error ...
> 

This is beyond the scope of ansible. You should have the rescue block do what 
is necessary to recover from your SQL script, or use something like a SQL 
transaction, but, again, it's beyond the scope of ansible.

V/r,
James Cassell

> So what to put in the rescue section?
> 
> Thanks for your help ! :)
> 
> Regards,
> 
> 
> Le mardi 14 mai 2019 18:01:00 UTC+2, Eric Hymowitz a écrit :
> >
> > The problem you have is that ansible does not retain the old state of the 
> > machine when it makes changes.  The fact that you executed the command 
> > "touch test_file.txt" does not indicate whether test_file.txt did or did 
> > not exist prior to running the command.  So to "roll back", do you erase 
> > the file?  Change the date-stamp back to what it was?
> >
> > Probably the closest thing you will find is a "block" with a "rescue" 
> > section attached, to specify what you want to happen in the event of an 
> > error.
> >
> > https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html
> >
> > --EbH
> >
> 

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


[ansible-project] Re: Rollback in Ansible ?

2019-05-14 Thread Ryad karkar
Hey,

It is really very interesting this section rescue but if in my block I 
execute for example a script sql which does a lot of actions and that there 
is an error ...

So what to put in the rescue section?

Thanks for your help ! :)

Regards,


Le mardi 14 mai 2019 18:01:00 UTC+2, Eric Hymowitz a écrit :
>
> The problem you have is that ansible does not retain the old state of the 
> machine when it makes changes.  The fact that you executed the command 
> "touch test_file.txt" does not indicate whether test_file.txt did or did 
> not exist prior to running the command.  So to "roll back", do you erase 
> the file?  Change the date-stamp back to what it was?
>
> Probably the closest thing you will find is a "block" with a "rescue" 
> section attached, to specify what you want to happen in the event of an 
> error.
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html
>
> --EbH
>

-- 
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/719ee931-0a2a-4790-a9c9-9e334e400d32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Rollback in Ansible ?

2019-05-14 Thread 'Eric Hymowitz' via Ansible Project
The problem you have is that ansible does not retain the old state of the 
machine when it makes changes.  The fact that you executed the command 
"touch test_file.txt" does not indicate whether test_file.txt did or did 
not exist prior to running the command.  So to "roll back", do you erase 
the file?  Change the date-stamp back to what it was?

Probably the closest thing you will find is a "block" with a "rescue" 
section attached, to specify what you want to happen in the event of an 
error.

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

--EbH

-- 
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/9576d408-ebbf-4cbe-b024-f25efaeb0476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Sorting dicts in lists - works different between my machine and others

2019-05-14 Thread Jon Spriggs
Hi,

I have a variable which is a list (sourced from registering the response
from a 3rd party module). In that list, each item is a dict, as follows:

[
  {'policyid': '1009', 'other': 'content'},
  {'policyid': '2019', 'other': 'content'},
  {'policyid': '1024', 'other': 'content'},
  {'policyid': '1000', 'other': 'content'},
  {'policyid': '8732', 'other': 'content'},
  {'policyid': '1012', 'other': 'content'}
]

I have some code that works locally on my machine:

- name: sort policy
  set_fact:
desired_policy: |
  [
{% for policy in fwpolicy.meta.results | sort(attribute='policyid')
%}
  {
'rule': '{{ policy.policyid }}',
'after': '{{ (loop.previtem | default({}) )['policyid'] |
default(0) }}',
'before': '{{ (loop.nextitem | default({}) )['policyid'] |
default(0) }}'
  },
{% endfor %}
  ]

When I run this on my machine, I get the following list:

[
  {'policyid': '1000', 'after': 0, 'before': 1009},
  {'policyid': '1009' , 'after': 1000, 'before': 1012},
  {'policyid': '1012' , 'after': 1009, 'before': 1024},
  {'policyid': '1024' , 'after': 1012, 'before': 2019},
  {'policyid': '2019' , 'after': 1024, 'before': 8732},
  {'policyid': '8732' , 'after': 2019, 'before': 0}
]

On my colleague's machine (and on AWX for that matter), I get:

[
  {'policyid': '1000', 'after': 0, 'before': 0},
  {'policyid': '1009' , 'after': 0, 'before': 0},
  {'policyid': '1012' , 'after': 0, 'before': 0},
  {'policyid': '1024' , 'after': 0, 'before': 0},
  {'policyid': '2019' , 'after': 0, 'before': 0},
  {'policyid': '8732' , 'after': 0, 'before': 0}
]

Am I doing something wrong, and should I be doing something differently?
--
Jon "The Nice Guy" Spriggs
@jontheniceguy everywhere...
https://jon.sprig.gs

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


Re: [ansible-project] Set variable to some value if undefined

2019-05-14 Thread Tuyen Nguyen
Hi

Thanks.  I will try this.  I think this should work.

On Monday, May 13, 2019 at 9:49:29 AM UTC-4, Brian Coca wrote:
>
> That is what the `default` filter is for: 
>
> when: install_office|default('n') == 'y' 
>
>
>
> -- 
> -- 
> Brian Coca 
>

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


[ansible-project] Execute the ipaddr filter after installation

2019-05-14 Thread Evgeniy Ivanov
Hi there, 

I've got a problem with the ipaddr filter. It doesn't seem to be loaded 
after installed in the same playbook:

example:

- pip: name=netaddr state=latest

- debug: msg="{{ '192.0.2.0' | ipaddr }}"

gives an error:

TASK [debug] 
>> ***
>
> fatal: [localhost]: FAILED! => {"msg": "The ipaddr filter requires 
>> python-netaddr be installed on the ansible controller"}
>
>
It seems that netaddr  should be in the system before evoking ansible.

Is there any workaround to load the filter in the same playbook?

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/49bc5af7-321a-4e98-8b9f-27ddd45c0e85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ansible_python_interpreter facts.d

2019-05-14 Thread Brian Coca
Ansible does not handle the 'interpreter' for facts.d scripts, it just
executes them, so you should be able to control the 'python used' by
altering the shebang.


--
Brian Coca

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


Re: [ansible-project] Rollback in Ansible ?

2019-05-14 Thread Ryad karkar
Hey,

Ok, thank you very much for your help !!

I will try rescue

Regards,

Le mardi 14 mai 2019 14:29:25 UTC+2, James Cassell a écrit :
>
>
>
> On Tue, May 14, 2019, at 8:04 AM, Ryad karkar wrote: 
> > Hey stefan, 
> > 
> > Yes but if i want one procedure for install one application, exemple: 
> > 
> > - block: 
> > 
> >  - name: task 1 
> > .. 
> > . 
> >   
> > - name: task 2 
> >   .. 
> >   .. 
> >   
> > i want that if one task fails, I want him to go back on all the tasks 
> that 
> > play it. 
> > 
>
> You can write rollback tasks in a `rescue` section, followed by a fail 
> task, but there is no automatic rollback functionality unless you write it 
> yourself. 
>
> V/r, 
> James Cassell 
>
> > Do you understand what i say or no ? 
> > 
> > Can you help me please :) 
> > 
> > Regards 
> > 
> > Le mardi 14 mai 2019 12:20:04 UTC+2, Stefan Hornburg (Racke) a écrit : 
> > > 
> > > On 5/14/19 11:54 AM, Ryad karkar wrote: 
> > > > Hey all, 
> > > > 
> > > > I want know when i play one task who failed if possible that ansible 
> do 
> > > rollback ? 
> > > > 
> > > > Exemple : 
> > > > 
> > > > - name: "create file" 
> > > >   shell: touch test_file.txt 
> > > > 
> > > > When i play this task, she failed so i want one task or method for 
> > > rollback please ? 
> > > 
> > > Hello Ryad, 
> > > 
> > > what do you have in mind for the rollback for this task. Usually, if 
> > > "touch" fails nothing changes on the target 
> > > system. 
> > > 
> > > > 
> > > > I see in documentation officielle the module *aci_config_rollback* 
> but i 
> > > don't konw how works this module... 
> > > > 
> > > > 
> > > 
> https://docs.ansible.com/ansible/latest/modules/aci_config_rollback_module.html
>  
> > > 
> > > That looks like it applies for a very specific use case. 
> > > 
> > > Regards 
> > > Racke 
> > > 
> > > > 
> > > > Can you help me ? 
> > > > 
> > > > Thanks community ansible !! :) 
> > > > 
> > > > Regards, 
> > > > 
>

-- 
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/4ffdd98e-d84d-4665-b667-2c6b598f2db1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Rollback in Ansible ?

2019-05-14 Thread James Cassell



On Tue, May 14, 2019, at 8:04 AM, Ryad karkar wrote:
> Hey stefan,
> 
> Yes but if i want one procedure for install one application, exemple:
> 
> - block:
> 
>  - name: task 1
> ..
> .
>  
> - name: task 2
>   ..
>   ..
>  
> i want that if one task fails, I want him to go back on all the tasks that 
> play it.
> 

You can write rollback tasks in a `rescue` section, followed by a fail task, 
but there is no automatic rollback functionality unless you write it yourself.

V/r,
James Cassell

> Do you understand what i say or no ?
> 
> Can you help me please :)
> 
> Regards
> 
> Le mardi 14 mai 2019 12:20:04 UTC+2, Stefan Hornburg (Racke) a écrit :
> >
> > On 5/14/19 11:54 AM, Ryad karkar wrote: 
> > > Hey all, 
> > > 
> > > I want know when i play one task who failed if possible that ansible do 
> > rollback ? 
> > > 
> > > Exemple : 
> > > 
> > > - name: "create file" 
> > >   shell: touch test_file.txt 
> > > 
> > > When i play this task, she failed so i want one task or method for 
> > rollback please ? 
> >
> > Hello Ryad, 
> >
> > what do you have in mind for the rollback for this task. Usually, if 
> > "touch" fails nothing changes on the target 
> > system. 
> >
> > > 
> > > I see in documentation officielle the module *aci_config_rollback* but i 
> > don't konw how works this module... 
> > > 
> > > 
> > https://docs.ansible.com/ansible/latest/modules/aci_config_rollback_module.html
> >  
> >
> > That looks like it applies for a very specific use case. 
> >
> > Regards 
> > Racke 
> >
> > > 
> > > Can you help me ? 
> > > 
> > > Thanks community ansible !! :) 
> > > 
> > > Regards, 
> > > 

-- 
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/1557836952.3071769.1669192264.7F0928F4%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Rollback in Ansible ?

2019-05-14 Thread Ryad karkar
Hey stefan,

Yes but if i want one procedure for install one application, exemple:

- block:

 - name: task 1
..
.
 
- name: task 2
  ..
  ..
 
i want that if one task fails, I want him to go back on all the tasks that 
play it.

Do you understand what i say or no ?

Can you help me please :)

Regards

Le mardi 14 mai 2019 12:20:04 UTC+2, Stefan Hornburg (Racke) a écrit :
>
> On 5/14/19 11:54 AM, Ryad karkar wrote: 
> > Hey all, 
> > 
> > I want know when i play one task who failed if possible that ansible do 
> rollback ? 
> > 
> > Exemple : 
> > 
> > - name: "create file" 
> >   shell: touch test_file.txt 
> > 
> > When i play this task, she failed so i want one task or method for 
> rollback please ? 
>
> Hello Ryad, 
>
> what do you have in mind for the rollback for this task. Usually, if 
> "touch" fails nothing changes on the target 
> system. 
>
> > 
> > I see in documentation officielle the module *aci_config_rollback* but i 
> don't konw how works this module... 
> > 
> > 
> https://docs.ansible.com/ansible/latest/modules/aci_config_rollback_module.html
>  
>
> That looks like it applies for a very specific use case. 
>
> Regards 
> Racke 
>
> > 
> > Can you help me ? 
> > 
> > Thanks community ansible !! :) 
> > 
> > Regards, 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to 
> > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To 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/5ef3adcb-671f-49d9-b4f7-db5afd6c835b%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/5ef3adcb-671f-49d9-b4f7-db5afd6c835b%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

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


Re: [ansible-project] Re: using inventory group name as var?

2019-05-14 Thread Matthew Arguin
ha..that did the trick!

thanks
-m

On Mon, May 13, 2019 at 9:27 AM Claudia de Luna  wrote:

> Hi Matthew,
>
> Not sure if this is what you are looking for but I use the host group name
> to create a custom directory to store files (basically show command output
> from network devices).
>
> I use the ansible facts group_name list which gives a list of all the
> groups to which the host belongs.  In my case each hosts belongs to just a
> single group so that list will contain one element which I reference as you
> see by group_names[0] and use it to build my custom directory (which I also
> time stamps so I get something like logs_cisco_2019-05-13 as my
> directory).   You do have to gather facts which might make your run a bit
> longer.
>
> *group_name*s is one of the Ansible "Magic" Variables and you can read
> more about those here:
>
> https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
>
> group_namesList of groups the current host is part of
>
> - hosts: cisco
>   gather_facts: yes
>
> - name: Create Directory
>   file:
> path: ./logs_{{ group_names[0] }}_{{ ansible_date_time.date }}
> state: directory
>
>
> Not sure thats what you were looking for but thought I would suggest on
> the off chance it is.
>
>
> On Friday, May 10, 2019 at 12:08:01 PM UTC-7, Matthew Arguin wrote:
>>
>> I am sure that i am just glossing over this in the documentation, but
>> here goes anyway:
>>
>> i am tryingto identify how i can use a hosts group name
>>
>> host_group_1:
>>host1:
>>host2:
>>
>> in such a way that i can call it in a task and use the actual name of the
>> group as a variable.
>>
>> if i run a playbook against host1 from above and  have a task that does a
>> lineinfile on /etc/somefile:
>>
>> line1
>> line2
>> line3
>> lineX
>>
>> the line that i am inserting would be "host_group_1" that i would do an
>> insertbefore "lineX"
>>
>> i am trying to avoid for every host group, having some variable with the
>> same name as the host group.  seems silly, redundant and avoidable.  I am
>> guessing that i am just not searching for the right thing in the
>> documentation.  any pointers?
>>
>>
>> --
> 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/7bbeca1d-19b7-46c5-94de-bc07d24311d4%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/CAKQi5VX6LTjfAK6e0BEkhb-DBSOpiq8k9471EKx7HeO9qKdbKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Configuring Management Jobs

2019-05-14 Thread Jonathan Lozada De La Matta
checkout the API documents for tower in ansible.com

On Tue, May 14, 2019 at 6:39 AM Mayank Kumar 
wrote:

> Hi All,
> Is there any way we can make changes in Management Jobs for ansible from
> config files?
> For example, I want to put "*Cleanup Activity Stream" *as 45 days but I
> am wondering if I can achieve it via some any config file instead of UI.
> This is because we want to set up multiple Ansible Towers and want to
> avoid making same "cleanup activity stream" changes across all tower.
>
>
> Thanks
> Mayank
>
> --
> 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/5a96fa55-20ed-43aa-b56f-a0c516b26123%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Automation Practice

Senior Automation Consultant & Automation CoP Manager

Red Hat 
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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/CAFYJA%2B%2B-fKF4BZ5ZcU_zs%2Bk_rs%3DLM7ca7nav--5n2AHt%2BZ2iXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Configuring Management Jobs

2019-05-14 Thread Mayank Kumar
Hi All,
Is there any way we can make changes in Management Jobs for ansible from 
config files?
For example, I want to put "*Cleanup Activity Stream" *as 45 days but I am 
wondering if I can achieve it via some any config file instead of UI.
This is because we want to set up multiple Ansible Towers and want to avoid 
making same "cleanup activity stream" changes across all tower.


Thanks
Mayank

-- 
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/5a96fa55-20ed-43aa-b56f-a0c516b26123%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Rollback in Ansible ?

2019-05-14 Thread Stefan Hornburg (Racke)
On 5/14/19 11:54 AM, Ryad karkar wrote:
> Hey all,
> 
> I want know when i play one task who failed if possible that ansible do 
> rollback ?
> 
> Exemple :
> 
> - name: "create file"
>   shell: touch test_file.txt
> 
> When i play this task, she failed so i want one task or method for rollback 
> please ?

Hello Ryad,

what do you have in mind for the rollback for this task. Usually, if "touch" 
fails nothing changes on the target
system.

> 
> I see in documentation officielle the module *aci_config_rollback* but i 
> don't konw how works this module...
> 
> https://docs.ansible.com/ansible/latest/modules/aci_config_rollback_module.html

That looks like it applies for a very specific use case.

Regards
Racke

> 
> Can you help me ?
> 
> Thanks community ansible !! :)
> 
> Regards,
> 
> -- 
> 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/5ef3adcb-671f-49d9-b4f7-db5afd6c835b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/ce22f797-2cd9-54f5-3154-6adcb8101729%40linuxia.de.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Unable to user aruba_command

2019-05-14 Thread Sudheer Satyanarayana

Hello,

I am trying to use the aruba_command:


Here's my playbook:

---
- hosts: all
  connection: local
  tasks:
  - name: run show version on remote devices
    aruba_command:
  commands: show version
  provider:
    username: admin
    password: admin
    host: 192.168.3.5


Here's the output:

ansible-playbook -i all, aruba.yml -vvv
ansible-playbook 2.7.8
  config file = /etc/ansible/ansible.cfg
  configured module search path = 
[u'/home/sudheer/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = 
/home/sudheer/.local/lib/python2.7/site-packages/ansible

  executable location = /home/sudheer/.local/bin/ansible-playbook
  python version = 2.7.15 (default, Oct 15 2018, 15:26:09) [GCC 8.2.1 
20180801 (Red Hat 8.2.1-2)]

Using /etc/ansible/ansible.cfg as config file
Parsed all, inventory source with host_list plugin
 [WARNING]: Found both group and host with same name: all


PLAYBOOK: aruba.yml 
***

1 plays in aruba.yml

PLAY [all] 



TASK [Gathering Facts] 


task path: /home/sudheer/aruba.yml:2
 ESTABLISH LOCAL CONNECTION FOR USER: sudheer
 EXEC /bin/sh -c 'echo ~sudheer && sleep 0'
 EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961 `" 
&& echo ansible-tmp-1557828965.19-207615568817961="` echo 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961 `" 
) && sleep 0'
Using module file 
/home/sudheer/.local/lib/python2.7/site-packages/ansible/modules/system/setup.py
 PUT /home/sudheer/.ansible/tmp/ansible-local-28452hbNPWC/tmpkiq8zK 
TO 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961/AnsiballZ_setup.py
 EXEC /bin/sh -c 'chmod u+x 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961/ 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961/AnsiballZ_setup.py 
&& sleep 0'
 EXEC /bin/sh -c '/usr/bin/python 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961/AnsiballZ_setup.py 
&& sleep 0'
 EXEC /bin/sh -c 'rm -f -r 
/home/sudheer/.ansible/tmp/ansible-tmp-1557828965.19-207615568817961/ > 
/dev/null 2>&1 && sleep 0'

ok: [all]
META: ran handlers

TASK [run show version on remote devices] 
*

task path: /home/sudheer/aruba.yml:5
<192.168.3.5> using connection plugin network_cli (was local)
The full traceback is:
Traceback (most recent call last):
  File "/home/sudheer/.local/bin/ansible-connection", line 106, in start
    self.connection._connect()
  File 
"/home/sudheer/.local/lib/python2.7/site-packages/ansible/plugins/connection/network_cli.py", 
line 336, in _connect

    self._terminal.on_open_shell()
  File 
"/home/sudheer/.local/lib/python2.7/site-packages/ansible/plugins/terminal/aruba.py", 
line 68, in on_open_shell

    raise AnsibleConnectionFailure('unable to set terminal parameters')
AnsibleConnectionFailure: unable to set terminal parameters

fatal: [all]: FAILED! => {
    "msg": "unable to set terminal parameters"
}
    to retry, use: --limit @/home/sudheer/aruba.retry

PLAY RECAP 


all    : ok=1    changed=0    unreachable=0 failed=1

What am I doing wrong?

-

Sudheer S

--
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/866a7b2d-3f5c-869d-d197-1fb9d511bebd%40techchorus.net.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Rollback in Ansible ?

2019-05-14 Thread Ryad karkar
Hey all,

I want know when i play one task who failed if possible that ansible do 
rollback ?

Exemple :

- name: "create file"
  shell: touch test_file.txt

When i play this task, she failed so i want one task or method for rollback 
please ?

I see in documentation officielle the module *aci_config_rollback* but i 
don't konw how works this module...

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

Can you help me ?

Thanks community ansible !! :)

Regards,

-- 
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/5ef3adcb-671f-49d9-b4f7-db5afd6c835b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Default filter issue

2019-05-14 Thread Daniel Vašek
This could work, but only if there is no such group. When the group exists, 
but its empty, it throws error.

Dne úterý 14. května 2019 9:50:36 UTC+2 Stefan Hornburg (Racke) napsal(a):
>
> On 5/14/19 9:23 AM, Daniel Vašek wrote: 
> > Hello, 
> > 
> > Im trying to use default filter: 
> > 
> > hosts: ["{{ groups['examples'][0] | default('localhost') }}":5045] 
> > 
> > 
> > But it return error: 
> > 
> > 
> > FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict 
> object' has no attribute 'examples'"}. 
> > 
> > 
> > I read something about default can use only 1 level deep, but I cannot 
> write more levels properly. 
>
> I suppose you have to accommodate the case where there is no examples 
> entry in "groups" (untested): 
>
> {% if 'examples' in groups %}groups['examples'][0] | 
> default('localhost'){% else %}localhost{% endif %} 
>
> Regards 
> Racke 
>
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to 
> > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To 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/ff9ef7e6-316d-455d-8fcc-945a033d5e4e%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/ff9ef7e6-316d-455d-8fcc-945a033d5e4e%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

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


Re: [ansible-project] Default filter issue

2019-05-14 Thread Sebastian Meyer
On 14.05.19 09:23, Daniel Vašek wrote:
> Hello,
> 
> Im trying to use default filter:
> 
> hosts: ["{{ groups['examples'][0] | default('localhost') }}":5045]
> 

You should be able to use: groups.examples.0 | default(...)

This is the one case where dot notation is simpler/better :)

Sebastian

> 
> But it return error:
> 
> 
> FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict 
> object' has no attribute 'examples'"}.
> 
> 
> I read something about default can use only 1 level deep, but I cannot 
> write more levels properly.
> 
> 
> 

-- 
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

-- 
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/f4953f3c-b75d-d2d4-09a6-30313f391e4f%40b1-systems.de.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Default filter issue

2019-05-14 Thread Stefan Hornburg (Racke)
On 5/14/19 9:23 AM, Daniel Vašek wrote:
> Hello,
> 
> Im trying to use default filter:
> 
> hosts: ["{{ groups['examples'][0] | default('localhost') }}":5045]
> 
> 
> But it return error:
> 
> 
> FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' 
> has no attribute 'examples'"}.
> 
> 
> I read something about default can use only 1 level deep, but I cannot write 
> more levels properly.

I suppose you have to accommodate the case where there is no examples entry in 
"groups" (untested):

{% if 'examples' in groups %}groups['examples'][0] | default('localhost'){% 
else %}localhost{% endif %}

Regards
Racke

> 
> 
> 
> -- 
> 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/ff9ef7e6-316d-455d-8fcc-945a033d5e4e%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To 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/03476eb6-a252-aa22-0544-917729d07ed9%40linuxia.de.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


[ansible-project] Default filter issue

2019-05-14 Thread Daniel Vašek
Hello,

Im trying to use default filter:

hosts: ["{{ groups['examples'][0] | default('localhost') }}":5045]


But it return error:


FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict 
object' has no attribute 'examples'"}.


I read something about default can use only 1 level deep, but I cannot 
write more levels properly.



-- 
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/ff9ef7e6-316d-455d-8fcc-945a033d5e4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.