Re: [ansible-project] Hooks in Ansible

2022-07-26 Thread Daniel Gonçalves

Hello, thank you for your answer!

What I understand about cache plugins is that what could interrest me is
fact caching. But as far as I know, lookup plugins can't set facts.

Regards,

Daniel


Le 2022-07-26 13:08, Todd Lewis a écrit :

Sounds like you want cache plugins.
https://docs.ansible.com/ansible/latest/plugins/cache.html

On 7/26/22 1:32 AM, Daniel Gonçalves wrote:


Thank you for you answer.

I already know *post_tasks*, *handlers*, and *ansible-runner*, but I
don't think there are good for what I'm looking for.

You need a bit more context: I have a custom lookup plugin that
initialize some data and execute a new process in order to keep
these datas available during the playbook life.
I want to be able to send a SIGTERM signal to the process to
terminate it at the end of playbook execution.

As I want to share this custom plugin, I don't want any user
interaction, because it's not the user role to worry about this
extra process.
So *post_tasks*, *handlers*, and *wait_for* are excluded.
*ansible-runner* may be a good alternative but I don't want to force
users to use *ansible-runner* instead of *ansible*.

I hope it's more clear.

Regards,

Daniel

Le 2022-07-25 21:55, Vladimir Botka a écrit :
On Mon, 25 Jul 2022 19:06:33 +0200
Daniel Gonçalves  wrote:

What I want to do is executing some code at the end of the playbook
execution, in other words executing some code at some arbitrary
playbook
execution step. I wonder if there is some event listener I can
subscribe
on in order to execute my code.

This depends on the use case:

1) To execute the code at the end of the playbook you can use
*post_tasks*. At some arbitrary playbook execution step use
*tasks*.

2) To trigger the execution of a code by some events you can use
the module *wait_for*



https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html#ansible-builtin-wait-for-module-waits-for-a-condition-before-continuing


and *handlers*



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


3) To execute the code after the playbook finished you can use
*ansible-runner*



https://ansible-runner.readthedocs.io/en/stable/python_interface/#usage-examples



--
Vladimir Botka


--
Todd

 --
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/07615b91-c41d-e3a7-422c-54e91af3b72e%40gmail.com
[1].


Links:
--
[1] 
https://groups.google.com/d/msgid/ansible-project/07615b91-c41d-e3a7-422c-54e91af3b72e%40gmail.com?utm_medium=email_source=footer


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


Re: [ansible-project] Hooks in Ansible

2022-07-26 Thread Daniel Gonçalves
Currently my plugin's process has a Time To Live concept to keep data 
during some customizable duration.
It's pretty similar to what *async* provides but the drawback is that 
you need to know in advance how many time the execution will take, and 
that's what I want to avoid.


Regards,

Daniel


Le 2022-07-26 10:57, Vladimir Botka a écrit :

On Tue, 26 Jul 2022 07:32:33 +0200
Daniel Gonçalves  wrote:


context: I have a custom lookup plugin that
initialize some data and execute a new process ...
I want to be able to send a SIGTERM signal to the process to
terminate it at the end of playbook execution.


This seems to be a candidate for *async*
https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html#run-tasks-concurrently-poll-0

--
Vladimir Botka


--
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/d2847c653de4e0c41a75b667d2b11d72%40lves.fr.


[ansible-project] How can I install TimescaleDB extension with Ansible?

2022-07-26 Thread 'BENFARHAT MohamedYoussef' via Ansible Project
I installed Postgresql and now I want to install his extension 
(TimescaleDB) but I can't find how to do it 

-- 
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/fd4ea951-fd98-4842-be96-fc9837e6f8bbn%40googlegroups.com.


[ansible-project] Ansible Tower Survey

2022-07-26 Thread Christopher Bachmeyer
Morning, community, 

Does anyone know if it is possible to store a Survey in a code repo like 
Git or somehow back Surveys up more generally?  I'm just not able to find a 
lot of info on this.

Thanks! 

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


Re: [ansible-project] Hooks in Ansible

2022-07-26 Thread Todd Lewis

Sounds like you want cache plugins.
https://docs.ansible.com/ansible/latest/plugins/cache.html

On 7/26/22 1:32 AM, Daniel Gonçalves wrote:

Thank you for you answer.

I already know *post_tasks*, *handlers*, and *ansible-runner*, but I 
don't think there are good for what I'm looking for.


You need a bit more context: I have a custom lookup plugin that 
initialize some data and execute a new process in order to keep these 
datas available during the playbook life.
I want to be able to send a SIGTERM signal to the process to terminate 
it at the end of playbook execution.


As I want to share this custom plugin, I don't want any user 
interaction, because it's not the user role to worry about this extra 
process.
So *post_tasks*, *handlers*, and *wait_for* are excluded. 
*ansible-runner* may be a good alternative but I don't want to force 
users to use *ansible-runner* instead of *ansible*.


I hope it's more clear.

Regards,

Daniel


Le 2022-07-25 21:55, Vladimir Botka a écrit :

On Mon, 25 Jul 2022 19:06:33 +0200
Daniel Gonçalves  wrote:


What I want to do is executing some code at the end of the playbook
execution, in other words executing some code at some arbitrary 
playbook
execution step. I wonder if there is some event listener I can 
subscribe

on in order to execute my code.


This depends on the use case:

1) To execute the code at the end of the playbook you can use
   *post_tasks*. At some arbitrary playbook execution step use
   *tasks*.

2) To trigger the execution of a code by some events you can use
   the module *wait_for*

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html#ansible-builtin-wait-for-module-waits-for-a-condition-before-continuing 


   and *handlers*
https://docs.ansible.com/ansible/latest/user_guide/playbooks_handlers.html

3) To execute the code after the playbook finished you can use
   *ansible-runner*

https://ansible-runner.readthedocs.io/en/stable/python_interface/#usage-examples 




--
Vladimir Botka




--
Todd

--
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/07615b91-c41d-e3a7-422c-54e91af3b72e%40gmail.com.


Re: [ansible-project] Hooks in Ansible

2022-07-26 Thread Vladimir Botka
On Tue, 26 Jul 2022 07:32:33 +0200
Daniel Gonçalves  wrote:

> context: I have a custom lookup plugin that 
> initialize some data and execute a new process ... 
> I want to be able to send a SIGTERM signal to the process to
> terminate it at the end of playbook execution.

This seems to be a candidate for *async*
https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html#run-tasks-concurrently-poll-0

-- 
Vladimir Botka

-- 
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/20220726105716.3a28b244%40gmail.com.


pgp1Zce6zqa6k.pgp
Description: OpenPGP digital signature


[ansible-project] Ansible-Playbook for fetch D-link switch Serial Number

2022-07-26 Thread Rajdeep Rathod
Hello,

I have multiple network switch. i want to get serial number using ansible 
play book.
here i have tried but not succeed.

In below example i have output of so many lines i have get only Serial 
Number Please help me...

*test.yml*

---

- name: switch
  hosts: switch
  gather_facts: false

  tasks:
- name: switch serial number check
  ios_command:
commands: show system
  register: output

- name: print output
  debug:
var: output.stdout_lines

Output :
PLAY [switch] 
***

TASK [switch serial number check] 
***
[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host 10.99.8.98 should 
use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility 
with prior
 Ansible releases. A future Ansible release will default to using the 
discovered
platform python for this host. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html
 for more information. This feature will be removed in version 2.12. 
Deprecation
warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.
ok: [10.99.8.98]

TASK [print output] 
*
ok: [10.99.8.98] => {
"output.stdout_lines": [
[
"Model Name  : DIS-F200-10PS",
"",
"System Description  : Industrial 8-P GbE RJ45 + 2 GbE 
RJ45/SFP Combo L2 Plus Managed PoE Switch",
"",
"Location: CCC",
"",
"Contact : ",
"",
"System Name : Stand-SWI-01",
"",
"System Date : 2022-07-26T13:07:05+05:30",
"",
"System Uptime   : 1d 17:06:28",
"",
"Bootloader Version  : v1.20",
"",
"Firmware Version: v7.10.2569 2020-05-15",
"",
"Hardware Version: v1.01",
"",
"Mechanical Version  : v1.01",
"",
"Serial Number   : RVF21J2000123",
"",
"MAC Address : #",
"",
"Memory  : Total=51778 KBytes, Free=32454 
KBytes, Max=31624 KBytes",
"",
"FLASH   : 0x4000-0x41ff, 512 x 
0x1 blocks",
"",
"Powers status   : Normal",
"",
"Powers  : PWR_1.0V:0.98V; PWR_3.3V:3.29V; 
PWR_2.5V:2.60V; PWR_1.8V:1.93V",
"",
"Temperature status  : Normal",
"",
"Temperature 1   : 46(C) ; 114(F)",
"",
"Temperature 2   : 49(C) ; 120(F)"
]
]
}

PLAY RECAP 
**
10.99.8.98 : ok=2changed=0unreachable=0failed=0 
   skipped=0rescued=0ignored=0



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