Re: [ansible-project] Re: Run the same handler only once through many playbooks notify

2021-03-15 Thread aori...@gmail.com
Thanks.
That's what I thought.

Le vendredi 12 mars 2021 à 20:45:49 UTC+1, Brian Coca a écrit :

> Handlers don't work that way, you CAN create some flag that will
> prevent it from running a 2nd time but there is no way to know 'this
> is the last notify'.
>
>
> -- 
> --
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9bd2fb42-e367-449d-9f4e-689c14299c1en%40googlegroups.com.


[ansible-project] Re: Run the same handler only once through many playbooks notify

2021-03-10 Thread aori...@gmail.com
Hi,

Thank you very much for the answer.

Unfortunetly, I don't think that it will answer my question.

I probably was not clear enough, and I'm sorry...
I thinks that what I'm asking is not possible due to handler scope, but I 
hope I'm wrong...

An example :

cat << EOF > playbook1.yml
- hosts: localhost
  gather_facts: no
  handlers:
- import_tasks: handler.yml
  tasks:
- debug:
msg: "Child playbook 1 - task 1"
  notify: "one handler"
  changed_when: True
- debug:
msg: "Child playbook 1 - task 2"
  notify: "one handler"
  changed_when: True
EOF

cat << EOF > playbook2.yml
- hosts: localhost
  gather_facts: no
  handlers:
- import_tasks: handler.yml
  tasks:
- debug:
msg: "Child playbook 2 - task 1"
  notify: "one handler"
  changed_when: True
- debug:
msg: "Child playbook 2 - task 2"
  notify: "one handler"
  changed_when: True
EOF

cat << EOF > playbook_parent.yml
- name: child playbook1
  import_playbook: playbook1.yml
- name: child playbook2
  import_playbook: playbook2.yml
EOF

cat << EOF > handler.yml
- name: "Handler"
  debug:
msg: "Handler"
  listen: "one handler"
EOF

Exécution of playbook_parent.yml : 
user-docker@6f808e321c8c:~$ ansible-playbook playbook_parent.yml
 [WARNING]: No inventory was parsed, only implicit localhost is available

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


PLAY [localhost] 
*

TASK [debug] 
*
changed: [localhost] => {
"msg": "Child playbook 1 - task 1"
}

TASK [debug] 
*
changed: [localhost] => {
"msg": "Child playbook 1 - task 2"
}

RUNNING HANDLER [Handler] 

ok: [localhost] => {
"msg": "Handler"
}

PLAY [localhost] 
*

TASK [debug] 
*
changed: [localhost] => {
"msg": "Child playbook 2 - task 1"
}

TASK [debug] 
*
changed: [localhost] => {
"msg": "Child playbook 2 - task 2"
}

RUNNING HANDLER [Handler] 

ok: [localhost] => {
"msg": "Handler"
}

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


The handler is run two times (one time after last notify in playbook1 and 
one after last notify in playbook2). I would like to run it only once at 
the last notify of all playbooks (here just after last notify in playbook2).

Le mardi 9 mars 2021 à 17:49:16 UTC+1, klingac a écrit :

> Hi,
>
> try to use "listen" in handlers definitions, e.g.:
> ```yaml
> handlers:
>   - name: Restart apache
> ansible.builtin.service:
>   name: apache
>   state: restarted
> listen: "restart web services"
> tasks:
>   - name: Restart everything
> ansible.builtin.command: echo "this task will restart the web services"
> notify: "restart web services"
> ```
> More info in documentation 
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_handlers.html
>
> Dne pondělí 8. března 2021 v 21:31:32 UTC+1 uživatel aori...@gmail.com 
> napsal:
>
>>
>> Hi everyone.
>>
>> Is there a way to run a handler once through multiple playbooks.
>>
>> Explanation :
>> I have a "master" playbook which imports several other playbooks.
>> I can run the "master" playbook or one individual playbook depending ot 
>> the situation.
>>
>> So

Re: [ansible-project] Slowness problèmes after upgrade from 2.8 to 2.9

2021-03-08 Thread aori...@gmail.com
We found the problems after many times and it's caused by 
https://github.com/ansible/ansible/issues/68763 
(we rollback to ansible 2.8 for some times and now we will work on our 
lookup and variables to fix the issue)
Thanks for the help anyway.
Have a nice day.

Le mercredi 21 octobre 2020 à 17:26:07 UTC+2, Quentin Aveno a écrit :

> Thanks for advice, I will take a look. 
>
> Le mer. 21 oct. 2020 à 14:04, Jorge Rúa  a écrit :
>
>> I *suspect* that issue might be caused by the newer ansible version 
>> which is potentially exhausting resources on the ansible controller node. 
>> Pay close attention to memory usage on the controller node when you're 
>> running ansible.
>>
>> El mié., 21 oct. 2020 a las 13:31, Quentin Aveno () 
>> escribió:
>>
>>> Hi everyone, 
>>> I have a slowness problem after upgrading ansible from ansible 2.8 to 
>>> ansible 2.9 (and from python 2.7 to python 3 only on controller). A lot of 
>>> differents taskes (and différents modules) became very slow (from seconds 
>>> to more than 5 minutes). After activating debug, I can see à kind of loop 
>>> over loading module:
>>> Loading Lookup Module '>> urlsplit/env/cordes/files/k8s/mathstuff/... each in turns> from 
>>> 
>>> More than 4000 times in à raw for each module. 
>>>
>>> Have you ever experimence this kind of slowness ? 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to ansible-proje...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/7c953cae-5d42-4637-9ecf-abaeeeb7fb82o%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-proje...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/CAFtje5MNKUVdsijWFrgTxgXBRgQKqiz7z7vyxq%3DwbuaiDDeEbQ%40mail.gmail.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/8d80b457-5029-4c27-9c42-66c6343108b1n%40googlegroups.com.


[ansible-project] Run the same handler only once through many playbooks notify

2021-03-08 Thread aori...@gmail.com

Hi everyone.

Is there a way to run a handler once through multiple playbooks.

Explanation :
I have a "master" playbook which imports several other playbooks.
I can run the "master" playbook or one individual playbook depending ot the 
situation.

Some of those playbooks notify the same handlers during key tasks.

But I have to run this handler only one time for all the playbook after the 
last notify.

Example :
master playbook:

   - playbook 1 :
  - prerequisite
  - install app1[notify handler] (<-do not run now but notify)
  - configure app1 [notify handler] (<-do not run now but notify)
   - playbook 2 :
   - prerequisite
  - install app2 [notify handler]  (<-do not run now but notify)
  - configure app2 [notify handler] (<- run now cause it's the last 
  notify)
  
If you have any idea, I would be grateful :)
Have a nice day.

-- 
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/261f3852-6f73-4f24-a2a4-8be35cefa088n%40googlegroups.com.