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

2021-03-09 Thread 'klingac' via Ansible Project
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.
>
> 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/3fe3e99b-1201-4cb6-9d3e-1edee0d962a5n%40googlegroups.com.


Re: [ansible-project] Unable to get correct disk space utilized percentage using Ansible API

2020-03-25 Thread klingac
It could be this kind of problem  
http://linuxshellaccount.blogspot.com/2008/12/why-du-and-df-display-different-values.html

`df` reads only and trusts completely to superblocks.

Another reason could be, that you can have other running process that can 
keep a deleted file open. 


Do you have any process

Dne středa 25. března 2020 17:54:07 UTC+1 Shifa Shaikh napsal(a):
>
> @Kia Hi, 
>
> As suggested I tried 
>
> item.size_total instead of item.size_available
>
>  "{{ ansible_host }}_{{ item.mount }}: {{ (100 * ((item.size_total - 
> item.size_available) / item.size_total)) | round(1, 'common') }}" 
>
>
>
> but it still gives me 22.2 % value instead of 19%
>
> Can you please let me know what's wrong and why the difference?
>
> On Wednesday, March 25, 2020 at 10:10:24 PM UTC+5:30, Kai Stian Olstad 
> wrote:
>>
>> On Wed, Mar 25, 2020 at 07:15:51AM -0700, Shifa Shaikh wrote: 
>> > 
>> > "{{ ansible_host }}_{{ item.mount }}: {{ (100 * ((item.size_total - 
>> item.size_available) / item.size_available)) | round(1, 'common') }}" 
>>
>> That is not how you calculate percentage, you need to divide on 
>> item.size_total 
>> and not item.size_available. 
>>
>> -- 
>> Kai Stian Olstad 
>>
>

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


Re: [ansible-project] Re: how to run one role out of a playbook host by host in serial one instead of linear or free

2020-03-16 Thread klingac
You can use throttle on block, hovewer it will not work as you need

https://github.com/ansible/ansible/issues/64659#issuecomment-564604298

Dne neděle 15. března 2020 16:57:44 UTC+1 Kai Stian Olstad napsal(a):
>
> On 14.03.2020 14:06, Jelle de Jong wrote: 
> > I would like to request the feature to apply serial:1 to blocks inside 
> > a 
> > role. 
> > 
> > I ended up in a futile attempt trying to use include and include_tasks 
> > without luck, and ended moving my whole block of tasks to a bash script 
> > with a locking system that waited it turn to run. I then called he 
> > script 
> > from ansible, lots of extra work. 
> > 
> >  - name: create a include_tasks to do a ipaddr calculation with 
> > throttle one 
> >include_tasks: 
> >  file: throttle01.yml 
> >  apply: 
> >throttle: 1 
>
> You can use throttle on a block 
>
> https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#id4
>  
>
> -- 
> Kai Stian Olstad 
>

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


[ansible-project] Re: Unable to access variables from host_vars dir however can access the same variables when specified in roles/defaults/mail.yml

2020-03-06 Thread klingac
Are you using `--limit` param for ansible-playbook?

Dne středa 4. března 2020 14:49:44 UTC+1 Vishal Bobade napsal(a):
>
>
> TASK [ansible-manage-lvm : manage_lvm | creating new LVM volume group(s)] 
> **
>  [0;31mfatal: [grafana]: FAILED! => {"msg": "'config_lv_name' is undefined"} 
> [0m
>  [0;31m [0m
>
>
>
>
>
> I am gettin the above error when I am trying to create and procure lvm 
> stuff on my new environment. I want to mention all the variables as a part 
> of host_vars like below:
>
> # lvm variablesvg_name: "VolGroup01"config_lv_name: "LogVol10"data_lv_name: 
> "LogVol11"lvm_disk_name: "/dev/nvme2n1"config_mntp: "/opt/tools"data_mntp: 
> "/data"config_lv_size: "50G"data_lv_size: "100G"
>
>
>
> I am trying to use them as below :
>
>
> lvm_groups:  - vgname: "{{ vg_name }}"disks:   - "{{ 
> lvm_disk_name }}"create: truelvnames:  - lvname: "{{ 
> config_lv_name }}"size: "{{ config_lv_size }}"create: 
> true  ## Mention "false" in case of lvm removalfilesystem: xfs
> mount: truemntp: "{{ config_mntp }}"  
> - lvname: "LogVol11"size: "{{ data_lv_size }}"create: 
> true  ## Mention "false" in case of lvm removalfilesystem: xfs
> mount: truemntp: "{{ data_mntp }}"manage_lvm: true
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Wednesday, March 4, 2020 at 7:10:36 PM UTC+5:30, Sagar Mujumale wrote:
>>
>> Whats the problem? where do you stuck. Please post more information.
>>
>> On Wednesday, 4 March 2020 18:54:29 UTC+5:30, Vishal Bobade wrote:
>>>
>>> I have created multiple inventory files specific to dev , qa etc env. 
>>> under inventory dir.
>>>
>>> inventory/dev.domain.net.yml 
>>>
>>> Any suggestions, would help as I am stucked here..
>>>
>>>
>>>

-- 
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/f6e8f0a5-8f17-4c69-9fde-3397cc22df59%40googlegroups.com.