I created test role to demostrate the problem, could be on github
https://github.com/hudecof/sensible_test

The output log on 8 different OS
- debian:7,8
- centos: 6,7
- ubuntu: 14.04, 16.04
- rhel: 6,7

is in logs directory
https://github.com/hudecof/sensible_test/blob/master/logs/full_run.log

As you can see, the task 01 for debian/ubuntu is run first, then is run
task 02, which is common for all servers and after that is run task 01
from centos/rhel.

On vars/os-XXXX.yml is the task order defined and I need to run the task
in that order, They are defendant ;(
Any advise?

        Peter

On 06/04/2017 23:57, Peter Hudec wrote:
> Hi,
> 
> I'm facin g following ISSUE.
> 
> My roles are mostly multi distribution enabled. My testing env is based
> on 8 different distribution/releases
>   - debian 7/8, ubuntu 14.04/16.04, centos 6/7, rhel 6/7
> 
> My way how to do distribution specific task is as follow
> 
> air-2:zabbix-agent hudecof$ cat tasks/main.yml
> ---
> # tasks file for zabbix-agent
> 
> - name: "common | set os specific variables"
>   include_vars: "{{ item }}"
>   with_first_found:
>    - "os-{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
>    - "os-{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
>    - "os-{{ ansible_distribution }}-{{
> ansible_distribution_major_version }}.yml"
>    - "os-{{ ansible_distribution }}.yml"
>    - "os-default.yml"
>   tags:
>     - zabbix-agent
> 
> - name: "run os specific tasks"
>   include: "{{ task_item }}"
>   with_items: "{{ zabbix_agent_tasks }}"
>   loop_control:
>     loop_var: task_item
>   tags:
>     - zabbix-agent
> 
> air-2:zabbix-agent hudecof$ cat vars/os-Debian.yml
> ---
> # list of packages to install
> zabbix_agent_tasks:
>   - packages-Debian.yml
>   - common-config.yml
>   - common-service.yml
>   - common-facts.yml
> 
> zabbix_agent_packages:
>   - zabbix-agent
> 
> # name of the service
> zabbix_agent_service: zabbix-agent
> 
> # user and group
> zabbix_agent_user: zabbix
> zabbix_agent_group: zabbix
> 
> 
> air-2:zabbix-agent hudecof$ cat vars/os-CentOS.yml
> ---
> # list of packages to install
> zabbix_agent_tasks:
>   - packages-CentOS.yml
>   - common-config.yml
>   - common-service.yml
>   - common-facts.yml
> 
> zabbix_agent_packages:
>   - zabbix-agent
> 
> # name of the service
> zabbix_agent_service: zabbix-agent
> 
> # user and group
> zabbix_agent_user: zabbix
> zabbix_agent_group: zabbix
> 
> 
> 
> When I run the role against full test set, the task execution order is like
> 
> TASK [zabbix-agent : common | set os specific variables]
> ***********************
> ok: [ditlcm01] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-Debian.yml)
> ok: [ditlcm04] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-Ubuntu.yml)
> ok: [ditlcm03] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-Ubuntu.yml)
> ok: [ditlcm05] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-CentOS.yml)
> ok: [ditlcm02] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-Debian.yml)
> ok: [ditlcm07] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-RedHat.yml)
> ok: [ditlcm06] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-CentOS.yml)
> ok: [ditlcm08] =>
> (item=/Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/vars/os-RedHat.yml)
> 
> TASK [zabbix-agent : run os specific tasks]
> ************************************
> included:
> /Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/tasks/packages-Debian.yml
> for ditlcm02, ditlcm03, ditlcm04, ditlcm01
> included:
> /Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/tasks/common-config.yml
> for ditlcm02, ditlcm03, ditlcm04, ditlcm05, ditlcm06, ditlcm07,
> ditlcm08, ditlcm01
> included:
> /Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/tasks/common-service.yml
> for ditlcm02, ditlcm03, ditlcm04, ditlcm05, ditlcm06, ditlcm07,
> ditlcm08, ditlcm01
> included:
> /Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/tasks/common-facts.yml
> for ditlcm02, ditlcm03, ditlcm04, ditlcm05, ditlcm06, ditlcm07,
> ditlcm08, ditlcm01
> included:
> /Users/hudecof/devel/github/ansible_roles/roles/zabbix-agent/tasks/packages-CentOS.yml
> for ditlcm05, ditlcm06, ditlcm07, ditlcm08
> 
> TASK [zabbix-agent : debian | install packages]
> ********************************
> changed: [ditlcm02] => (item=[u'zabbix-agent'])
> changed: [ditlcm03] => (item=[u'zabbix-agent'])
> changed: [ditlcm04] => (item=[u'zabbix-agent'])
> changed: [ditlcm01] => (item=[u'zabbix-agent'])
> 
> TASK [zabbix-agent : create directories]
> ***************************************
> failed: [ditlcm05] (item=/etc/zabbix/scripts) => {"failed": true,
> "file_item": "/etc/zabbix/scripts", "gid": 0, "group": "root", "mode":
> "0755", "msg": "chgrp failed: failed to look up group zabbix", "owner":
> "root", "path": "/etc/zabbix/scripts", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 4096, "state": "directory",
> "uid": 0}
> changed: [ditlcm02] => (item=/etc/zabbix/scripts)
> changed: [ditlcm03] => (item=/etc/zabbix/scripts)
> changed: [ditlcm01] => (item=/etc/zabbix/scripts)
> changed: [ditlcm04] => (item=/etc/zabbix/scripts)
> changed: [ditlcm02] => (item=/etc/zabbix/zabbix_agentd.d)
> changed: [ditlcm01] => (item=/etc/zabbix/zabbix_agentd.d)
> failed: [ditlcm05] (item=/etc/zabbix/zabbix_agentd.d) => {"failed":
> true, "file_item": "/etc/zabbix/zabbix_agentd.d", "gid": 0, "group":
> "root", "mode": "0755", "msg": "chgrp failed: failed to look up group
> zabbix", "owner": "root", "path": "/etc/zabbix", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 4096, "state": "directory",
> "uid": 0}
> changed: [ditlcm03] => (item=/etc/zabbix/zabbix_agentd.d)
> changed: [ditlcm04] => (item=/etc/zabbix/zabbix_agentd.d)
> failed: [ditlcm07] (item=/etc/zabbix/zabbix_agentd.d) => {"failed":
> true, "file_item": "/etc/zabbix/zabbix_agentd.d", "gid": 0, "group":
> "root", "mode": "0755", "msg": "chgrp failed: failed to look up group
> zabbix", "owner": "root", "path": "/etc/zabbix", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 4096, "state": "directory",
> "uid": 0}
> failed: [ditlcm06] (item=/etc/zabbix/zabbix_agentd.d) => {"failed":
> true, "file_item": "/etc/zabbix/zabbix_agentd.d", "gid": 0, "group":
> "root", "mode": "0755", "msg": "chgrp failed: failed to look up group
> zabbix", "owner": "root", "path": "/etc/zabbix", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 4096, "state": "directory",
> "uid": 0}
> failed: [ditlcm08] (item=/etc/zabbix/zabbix_agentd.d) => {"failed":
> true, "file_item": "/etc/zabbix/zabbix_agentd.d", "gid": 0, "group":
> "root", "mode": "0755", "msg": "chgrp failed: failed to look up group
> zabbix", "owner": "root", "path": "/etc/zabbix", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 6, "state": "directory", "uid": 0}
> failed: [ditlcm07] (item=/etc/zabbix/scripts) => {"failed": true,
> "file_item": "/etc/zabbix/scripts", "gid": 0, "group": "root", "mode":
> "0755", "msg": "chgrp failed: failed to look up group zabbix", "owner":
> "root", "path": "/etc/zabbix/scripts", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 4096, "state": "directory",
> "uid": 0}
> failed: [ditlcm06] (item=/etc/zabbix/scripts) => {"failed": true,
> "file_item": "/etc/zabbix/scripts", "gid": 0, "group": "root", "mode":
> "0755", "msg": "chgrp failed: failed to look up group zabbix", "owner":
> "root", "path": "/etc/zabbix/scripts", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 4096, "state": "directory",
> "uid": 0}
> failed: [ditlcm08] (item=/etc/zabbix/scripts) => {"failed": true,
> "file_item": "/etc/zabbix/scripts", "gid": 0, "group": "root", "mode":
> "0755", "msg": "chgrp failed: failed to look up group zabbix", "owner":
> "root", "path": "/etc/zabbix/scripts", "secontext":
> "unconfined_u:object_r:etc_t:s0", "size": 6, "state": "directory", "uid": 0}
> 
> TASK [zabbix-agent : create zabbix-agentd.conf]
> ********************************
> changed: [ditlcm01]
> changed: [ditlcm04]
> changed: [ditlcm03]
> changed: [ditlcm02]
> 
> TASK [zabbix-agent : copy include directory]
> ***********************************
> 
> TASK [zabbix-agent : copy script directory]
> ************************************
> 
> TASK [zabbix-agent : ensure zabbix agent started/stopped]
> **********************
> ok: [ditlcm02]
> ok: [ditlcm01]
> ok: [ditlcm03]
> changed: [ditlcm04]
> 
> TASK [zabbix-agent : create facts.d directory]
> *********************************
> changed: [ditlcm04]
> changed: [ditlcm02]
> changed: [ditlcm01]
> changed: [ditlcm03]
> 
> TASK [zabbix-agent : create facts file]
> ****************************************
> changed: [ditlcm02]
> changed: [ditlcm01]
> changed: [ditlcm04]
> changed: [ditlcm03]
> 
> RUNNING HANDLER [zabbix-agent : restart zabbix-agent]
> **************************
> changed: [ditlcm03]
> changed: [ditlcm04]
> changed: [ditlcm02]
> changed: [ditlcm01]
>       to retry, use: --limit @./.ansible/retry/zabbix.retry
> 
> PLAY RECAP
> *********************************************************************
> ditlcm01                   : ok=21   changed=6    unreachable=0
> failed=0
> ditlcm02                   : ok=21   changed=6    unreachable=0
> failed=0
> ditlcm03                   : ok=21   changed=6    unreachable=0
> failed=0
> ditlcm04                   : ok=21   changed=7    unreachable=0
> failed=0
> ditlcm05                   : ok=14   changed=0    unreachable=0
> failed=1
> ditlcm06                   : ok=14   changed=0    unreachable=0
> failed=1
> ditlcm07                   : ok=14   changed=0    unreachable=0
> failed=1
> ditlcm08                   : ok=14   changed=0    unreachable=0
> failed=1
> 
> 
> That means, the ansible is executing the debian package install on
> debian based distributions /common for debian and ubuntu/, then is
> running tasks common for all distributions ..
> And that the problem.. I need to run the CentOS/ReadHat install package
> tasks before, see the errors
> 
> Workaround is to set serial to 1, but this not a option ;(
> 


-- 
*Peter Hudec*
Infraštruktúrny architekt
[email protected] <mailto:[email protected]>

*CNC, a.s.*
Borská 6, 841 04 Bratislava
Recepcia: +421 2  35 000 100

Mobil:+421 905 997 203
*www.cnc.sk* <http:///www.cnc.sk>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/64aa39a7-1f56-f59a-667e-1302210ff3da%40cnc.sk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to