Untitled

                Never    
YAML
       
********** THIS WORKS, I CAN GET THE ROLE FROM THIS *******************
- name: Template required files to hosts
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: "{{ item.owner|default('root')}}"
    group: "{{ item.group|default('root')}}"
    mode: "{{ item.mode|default('0640') }}"
  when: dbsync_mariadb_role in item.role
  with_items:
    - { src: "dbsync.mariadb.sh.j2", dest: "{{ dbsync_mariadb_file_script_path }}", owner: "{{ dbsync_mariadb_file_script_owner }}", group: "{{ dbsync_mariadb_file_script_group }}", mode: "{{ dbsync_mariadb_file_script_mode }}", role: "restore" }
    - { src: "dbsync.mariadb.conf.j2", dest: "{{ dbsync_mariadb_file_config_path }}", owner: "{{ dbsync_mariadb_file_config_owner }}", group: "{{ dbsync_mariadb_file_config_group }}", mode: "{{ dbsync_mariadb_file_config_mode }}", role: "restore" }
    - { src: "sudoers.j2", dest: "{{ dbsync_mariadb_file_sudoers_path }}", owner: "{{ dbsync_mariadb_file_sudoers_owner }}", group: "{{ dbsync_mariadb_file_sudoers_group }}", mode: "{{ dbsync_mariadb_file_sudoers_mode }}", role: {"backup","cluster"} }
  become: yes



********** THIS DON'T WORK. I CAN'T GET item.role *******************
- name: Template required files to hosts
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    owner: "{{ item.owner|default('root')}}"
    group: "{{ item.group|default('root')}}"
    mode: "{{ item.mode|default('0640') }}"
  when: dbsync_mariadb_role in item.role
  with_items:
  with_items:
    - dbsync_mariadb_file_script
    - dbsync_mariadb_file_config
    - dbsync_mariadb_file_sudoers
  become: yes


********** GROUP VARS *************
dbsync_mariadb_file_script:
  path:  "/tmp/dbsync.mariadb.sh"
  src:   "dbsync.mariadb.sh.j2"
  owner: "root"
  group: "root"
  mode:  "0744"
  role:  "restore"

dbsync_mariadb_file_config:
  path:  "/etc/dbsync.mariadb.conf"
  src:   "dbsync.mariadb.conf.j2"
  owner: "root"
  group: "root"
  mode:  "0600"
  role:  "restore"

dbsync_mariadb_file_sudoers:
  path:  "/etc/sudoers.d/dbsync_mariadb"
  src:   "sudoers.j2"
  owner: "root"
  group: "root"
  mode:  "0440"
  role:  "backup"