diff --git a/roles/common/tasks/webadmin-user.yml b/roles/common/tasks/webadmin-user.yml index 78dd1a3..43bbb70 100644 --- a/roles/common/tasks/webadmin-user.yml +++ b/roles/common/tasks/webadmin-user.yml @@ -12,7 +12,7 @@ loop_control: label: "{{ item.name }}" when: - - groups['webadmin']|string is search(inventory_hostname) + - inventory_hostname in (groups['webadmin'] | default([])) - webadmin_user is defined - item.group_id is defined tags: @@ -33,14 +33,14 @@ loop_control: label: "{{ item.name }}" when: - - groups['webadmin']|string is search(inventory_hostname) + - inventory_hostname in (groups['webadmin'] | default([])) - webadmin_user is defined tags: - webadmin - users-exists - name: (webadmin-user.yml) Ensure authorized_key files for webadmin user is present - authorized_key: + ansible.posix.authorized_key: user: "{{ item.0.name }}" key: "{{ item.1 }}" state: present @@ -51,7 +51,7 @@ label: "{{ item.0.name }} key: {{ idx + 1 }}" index_var: idx when: - - groups['webadmin']|string is search(inventory_hostname) + - inventory_hostname in (groups['webadmin'] | default([])) - webadmin_user is defined tags: - webadmin @@ -64,7 +64,7 @@ owner: "{{ item.login }}" group: "{{ item.login }}" mode: "0600" - #when: groups['oopen_server']|string is search(inventory_hostname) + # when: groups['oopen_server']|string is search(inventory_hostname) when: - insert_webadmin_ssh_keypair|bool with_items: "{{ webadmin_ssh_keypair }}" @@ -105,9 +105,9 @@ # devel-repos contains SVN repositiries; webadmin must have ssh access to # to webadmin at devel-repos to manage SVN repository -# +# - name: (webadmin-user.yml) Ensure authorized_key on devel-repos hosts contains public key - authorized_key: + ansible.posix.authorized_key: user: "{{ item.login }}" key: "{{ lookup('file', item.pub_key_src) }}" state: present @@ -125,45 +125,46 @@ # --- - name: (users-systemfiles.yml) Check if local template directory exists for webadmin - ansible.builtin.stat: path={{ inventory_dir }}/files/homedirs/{{ item.name }} + ansible.builtin.stat: + path: "{{ inventory_dir }}/files/homedirs/{{ item.name }}" delegate_to: localhost with_items: "{{ webadmin_user }}" loop_control: label: "{{ item.name }}" - register: local_template_dir_webadmin + register: common_local_template_dir_webadmin # -- # Copy .bashrc # --- -#- name: (webadmin-user.yml) Check if webadmin's file '.bashrc.ORIG' exists -# stat: -# path: "~{{ item.item.name }}/.bashrc.ORIG" -# register: bashrc_webadmin_orig_exists -# with_items: "{{ local_template_dir_webadmin.results }}" -# loop_control: -# label: '{{ item.item.name }}' -# when: +# - name: (webadmin-user.yml) Check if webadmin's file '.bashrc.ORIG' exists +# stat: +# path: "~{{ item.item.name }}/.bashrc.ORIG" +# register: common_bashrc_webadmin_orig_exists +# with_items: "{{ common_local_template_dir_webadmin.results }}" +# loop_control: +# label: '{{ item.item.name }}' +# when: # - item.stat.exists -# tags: -# - webadmin -# - bash +# tags: +# - webadmin +# - bash # -#- name: (webadmin-user.yml) Backup existing webadmin's .bashrc file -# command: cp ~{{ item.item.item.name }}/.bashrc ~{{ item.item.item.name }}/.bashrc.ORIG -# loop: "{{ bashrc_webadmin_orig_exists.results }}" -# loop_control: -# label: '{{ item.item.item.name }}' -# when: -# - item.stat.exists == False -# tags: -# - webadmin -# - bash +# - name: (webadmin-user.yml) Backup existing webadmin's .bashrc file +# command: cp ~{{ item.item.item.name }}/.bashrc ~{{ item.item.item.name }}/.bashrc.ORIG +# loop: "{{ common_bashrc_webadmin_orig_exists.results }}" +# loop_control: +# label: '{{ item.item.item.name }}' +# when: +# - item.stat.exists +# tags: +# - webadmin +# - bash - name: (webadmin-user.yml) Check if webadmin's file '.bashrc.ORIG' exists ansible.builtin.stat: path: "~{{ item.name }}/.bashrc.ORIG" - register: bashrc_webadmin_orig_exists + register: common_bashrc_webadmin_orig_exists with_items: "{{ webadmin_user }}" loop_control: label: "{{ item.name }}" @@ -172,12 +173,12 @@ - bash - name: (webadmin-user.yml) Backup existing webadmin's .bashrc file - ansible.builtin.command: cp -a ~{{ item.item.name }}/.bashrc ~{{ item.item.name }}/.bashrc.ORIG - loop: "{{ bashrc_webadmin_orig_exists.results }}" + ansible.builtin.command: + cmd: cp -a ~{{ item.item.name }}/.bashrc ~{{ item.item.name }}/.bashrc.ORIG + creates: "~{{ item.item.name }}/.bashrc.ORIG" + loop: "{{ common_bashrc_webadmin_orig_exists.results }}" loop_control: label: "{{ item.item.name }}" - when: - - item.stat.exists == False tags: - webadmin - bash @@ -206,7 +207,7 @@ - name: (webadmin-user.yml) Check if webadmin's file '.profile.ORIG' exists ansible.builtin.stat: path: "~{{ item.name }}/.profile.ORIG" - register: profile_webadmin_orig_exists + register: common_profile_webadmin_orig_exists with_items: "{{ webadmin_user }}" loop_control: label: "{{ item.name }}" @@ -215,12 +216,12 @@ - profile - name: (webadmin-user.yml) Backup existing users .profile file - ansible.builtin.command: cp -a ~{{ item.item.name }}/.profile ~{{ item.item.name }}/.profile.ORIG - with_items: "{{ profile_webadmin_orig_exists.results }}" + ansible.builtin.command: + cmd: cp -a ~{{ item.item.name }}/.profile ~{{ item.item.name }}/.profile.ORIG + creates: "~{{ item.item.name }}/.profile.ORIG" + with_items: "{{ common_profile_webadmin_orig_exists.results }}" loop_control: label: "{{ item.item.name }}" - when: - - item.stat.exists == False tags: - webadmin - profile @@ -263,10 +264,11 @@ - webadmin - vim -- name: (webadmin-user.yml) Check if local template directory .vim exists for webadmin - ansible.builtin.stat: path={{ inventory_dir }}/files/homedirs/webadmin/.vim +- name: (webadmin-user.yml) Check if local template directory .vim exists for webadmin + ansible.builtin.stat: + path: "{{ inventory_dir }}/files/homedirs/webadmin/.vim" delegate_to: localhost - register: local_template_dir_vim_webadmin + register: common_local_template_dir_vim_webadmin with_items: "{{ webadmin_user }}" loop_control: label: "{{ item.name }}" @@ -278,7 +280,7 @@ owner: "{{ item.item.name }}" group: "{{ item.item.name }}" mode: "0644" - with_items: "{{ local_template_dir_vim_webadmin.results }}" + with_items: "{{ common_local_template_dir_vim_webadmin.results }}" loop_control: label: "{{ item.item.name }}" when: