---

  - name: Create BWC RBAC directories
    become: yes
    file:
      path: "{{ item }}"
      mode: "u+rw,g-wx,o-rwx"
      owner: st2
      group: st2
      state: directory
    with_items:
      - /opt/stackstorm/rbac/assignments
      - /opt/stackstorm/rbac/roles

  - name: Copy default assignments to RBAC directory
    become: yes
    template:
      src: "{{ item }}"
      dest: /opt/stackstorm/rbac/assignments/{{ item | basename | regex_replace('\.j2','') }}
      owner: st2
      group: st2
    with_fileglob:
      - rbac_assignments/*
    when: rbac_setup_default_assignments is defined and bwc_superuser is defined

  - name: Copy user supplied RBAC roles to the box
    template:
      src: "{{ item }}"
      dest: /opt/stackstorm/rbac/roles/"{{ item | basename | regex_replace('\.j2','') }}"
      owner: st2
      group: st2
    with_fileglob:
      - '"{{ rbac_roles_src_path }}"/*.j2'
    when: rbac_roles_src_path is defined

  - name: Copy user supplied RBAC assignments to the box
    template:
      src: "{{ item }}"
      dest: /opt/stackstorm/rbac/assignments/"{{ item | basename | regex_replace('\.j2','') }}"
      owner: st2
      group: st2
    with_fileglob:
      - '"{{ rbac_assignments_src_path }}"/*.j2'
    when: rbac_assignments_src_path is defined

  - name: Enable RBAC in st2 configuration
    become: yes
    ini_file:
      dest: /etc/st2/st2.conf
      section: auth
      option: enable
      value: True
      backup: yes
    notify:
      - restart st2
      - reload bwc_rbac
      - restart st2api

---

  - name: Create BWC RBAC directories
    become: yes
    file:
      path: "{{ item }}"
      mode: "u+rw,g-wx,o-rwx"
      owner: st2
      group: st2
      state: directory
    with_items:
      - /opt/stackstorm/rbac/assignments
      - /opt/stackstorm/rbac/roles

  - name: Copy default assignments to RBAC directory
    become: yes
    template:
      src: "{{ item }}"
      dest: /opt/stackstorm/rbac/assignments/{{ item | basename | regex_replace('\.j2','') }}
      owner: st2
      group: st2
    with_fileglob:
      - rbac_assignments/*
    when: rbac_setup_default_assignments is defined and bwc_superuser is defined

  - name: Enable RBAC in st2 configuration
    become: yes
    ini_file:
      dest: /etc/st2/st2.conf
      section: auth
      option: enable
      value: True
      backup: yes
    notify:
      - restart st2
      - reload bwc_rbac
      - restart st2api

Remove support for user supplied RBAC roles&assignments
Remove support for user supplied RBAC roles&assignments
