fix(webadmin-user.yml): update inventory checks and standardize variable names for clarity
This commit is contained in:
@@ -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
|
||||
@@ -107,7 +107,7 @@
|
||||
# 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,12 +125,13 @@
|
||||
# ---
|
||||
|
||||
- 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
|
||||
@@ -139,8 +140,8 @@
|
||||
# - 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 }}"
|
||||
# register: common_bashrc_webadmin_orig_exists
|
||||
# with_items: "{{ common_local_template_dir_webadmin.results }}"
|
||||
# loop_control:
|
||||
# label: '{{ item.item.name }}'
|
||||
# when:
|
||||
@@ -151,11 +152,11 @@
|
||||
#
|
||||
# - 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: "{{ common_bashrc_webadmin_orig_exists.results }}"
|
||||
# loop_control:
|
||||
# label: '{{ item.item.item.name }}'
|
||||
# when:
|
||||
# - item.stat.exists == False
|
||||
# - item.stat.exists
|
||||
# tags:
|
||||
# - webadmin
|
||||
# - bash
|
||||
@@ -163,7 +164,7 @@
|
||||
- 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
|
||||
@@ -264,9 +265,10 @@
|
||||
- vim
|
||||
|
||||
- name: (webadmin-user.yml) Check if local template directory .vim exists for webadmin
|
||||
ansible.builtin.stat: path={{ inventory_dir }}/files/homedirs/webadmin/.vim
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user