Fix errors checking if local template directory exists.

This commit is contained in:
Christoph 2019-07-09 01:01:06 +02:00
parent 185a7bce72
commit ccebad0f6c
4 changed files with 81 additions and 38 deletions

View File

@ -144,7 +144,6 @@ apt_initial_install_stretch:
- iputils-ping - iputils-ping
- apt-utils - apt-utils
- aptitude - aptitude
- apt-transport-https
- zip - zip
- unzip - unzip
- bzip2 - bzip2
@ -257,7 +256,6 @@ apt_initial_install_buster:
- iputils-ping - iputils-ping
- apt-utils - apt-utils
- aptitude - aptitude
- apt-transport-https
- zip - zip
- unzip - unzip
- bzip2 - bzip2
@ -826,6 +824,10 @@ git_mailserver_repositories:
repo: https://git.oopen.de/install/php repo: https://git.oopen.de/install/php
dest: /usr/local/src/php dest: /usr/local/src/php
- name: mysql
repo: https://git.oopen.de/install/mysql
dest: /usr/local/src/mysql
- name: mailsystem - name: mailsystem
repo: https://git.oopen.de/install/mailsystem repo: https://git.oopen.de/install/mailsystem
dest: /usr/local/src/mailsystem dest: /usr/local/src/mailsystem

2
hosts
View File

@ -151,6 +151,7 @@ a.ns.oopen.de
# - local network ckubu # - local network ckubu
gw-ckubu.local.netz gw-ckubu.local.netz
gw-akb.akb.netz
# - GA - Gemeinschaft Altensclirf # - GA - Gemeinschaft Altensclirf
ga-st-lxc1.ga.netz ga-st-lxc1.ga.netz
@ -938,6 +939,7 @@ a.ns.oopen.de
# --- # ---
gw-ckubu.local.netz gw-ckubu.local.netz
gw-akb.akb.netz
[warenform_server] [warenform_server]

View File

@ -1,5 +1,22 @@
--- ---
# ---
# Check if local template directories exists
# ---
# default_users
- name: (users-systemfiles.yml) Check if local template directory exists for default users
local_action: stat path={{ inventory_dir }}/files/homedirs/{{ item.name }}
with_items: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
register: local_template_dir_default_user
# root
- name: (users-systemfiles.yml) Check if local template directory exists for root
local_action: stat path={{ inventory_dir }}/files/homedirs/root
register: local_template_dir_root
# -- # --
# Copy .bashrc # Copy .bashrc
# --- # ---
@ -19,24 +36,23 @@
loop: "{{ bashrc_user_orig_exists.results }}" loop: "{{ bashrc_user_orig_exists.results }}"
loop_control: loop_control:
label: '{{ item.item.name }}' label: '{{ item.item.name }}'
#with_items: "{{ bashrc_user_orig_exists.results }}"
when: item.stat.exists == False when: item.stat.exists == False
tags: tags:
- bash - bash
- name: (users-systemfiles.yml) copy .bashrc if it exists - name: (users-systemfiles.yml) copy .bashrc if it exists
copy: copy:
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_bashrc') }}" src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_bashrc') }}"
dest: "~{{ item.name }}/.bashrc" dest: "~{{ item.item.name }}/.bashrc"
owner: "{{ item.name }}" owner: "{{ item.item.name }}"
group: "{{ item.name }}" group: "{{ item.item.name }}"
mode: 0644 mode: 0644
loop: "{{ default_user }}" loop: "{{ local_template_dir_default_user.results}}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.item.name }}'
when: when:
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name) - item.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_bashrc') - lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_bashrc')
tags: tags:
- bash - bash
@ -61,7 +77,7 @@
group: root group: root
mode: 0644 mode: 0644
when: when:
- lookup('fileglob', inventory_dir + '/files/homedirs/root') - local_template_dir_root.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/root/_bashrc') - lookup('fileglob', inventory_dir + '/files/homedirs/root/_bashrc')
tags: tags:
- bash - bash
@ -91,17 +107,17 @@
- name: (users-systemfiles.yml) copy .profile if it exists - name: (users-systemfiles.yml) copy .profile if it exists
copy: copy:
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_profile') }}" src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_profile') }}"
dest: "~{{ item.name }}/.profile" dest: "~{{ item.item.name }}/.profile"
owner: "{{ item.name }}" owner: "{{ item.item.name }}"
group: "{{ item.name }}" group: "{{ item.item.name }}"
mode: 0644 mode: 0644
loop: "{{ default_user }}" loop: "{{ local_template_dir_default_user.results }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.item.name }}'
when: when:
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name) - item.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_profile') - lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_profile')
tags: tags:
- profile - profile
@ -126,7 +142,7 @@
group: root group: root
mode: 0644 mode: 0644
when: when:
- lookup('fileglob', inventory_dir + '/files/homedirs/root') - local_template_dir_root.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/root/_profile') - lookup('fileglob', inventory_dir + '/files/homedirs/root/_profile')
tags: tags:
- profile - profile
@ -137,17 +153,17 @@
- name: (users-systemfiles.yml) copy .vimrc if it exists - name: (users-systemfiles.yml) copy .vimrc if it exists
copy: copy:
src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc') }}" src: "{{ lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_vimrc') }}"
dest: "~{{ item.name }}/.vimrc" dest: "~{{ item.item.name }}/.vimrc"
owner: "{{ item.name }}" owner: "{{ item.item.name }}"
group: "{{ item.name }}" group: "{{ item.item.name }}"
mode: 0644 mode: 0644
loop: "{{ default_user }}" loop: "{{ local_template_dir_default_user.results }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.item.name }}'
when: when:
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name) - item.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc') - lookup('fileglob', inventory_dir + '/files/homedirs/' + item.item.name + '/_vimrc')
tags: tags:
- vim - vim
@ -159,8 +175,8 @@
group: root group: root
mode: 0644 mode: 0644
when: when:
- lookup('fileglob', inventory_dir + '/files/homedirs/root') - local_template_dir_root.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc') - lookup('fileglob', inventory_dir + '/files/homedirs/root/_vimrc')
tags: tags:
- vim - vim

View File

@ -121,6 +121,15 @@
- insert_webadmin_ssh_public_key - insert_webadmin_ssh_public_key
# ---
# Check if local temlate directories exists
# ---
- name: (users-systemfiles.yml) Check if local template directory exists for webadmin
local_action: stat path={{ inventory_dir }}/files/homedirs/webadmin
register: local_template_dir_webadmin
# -- # --
# Copy .bashrc # Copy .bashrc
# --- # ---
@ -132,6 +141,8 @@
with_items: "{{ webadmin_user }}" with_items: "{{ webadmin_user }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.name }}'
when:
- local_template_dir_webadmin.stat.exists
tags: tags:
- webadmin - webadmin
- bash - bash
@ -141,7 +152,9 @@
with_items: "{{ bashrc_webadmin_orig_exists.results }}" with_items: "{{ bashrc_webadmin_orig_exists.results }}"
loop_control: loop_control:
label: '{{ item.item.name }}' label: '{{ item.item.name }}'
when: item.stat.exists == False when:
- local_template_dir_webadmin.stat.exists
- item.stat.exists == False
tags: tags:
- webadmin - webadmin
- bash - bash
@ -156,7 +169,9 @@
with_items: "{{ webadmin_user }}" with_items: "{{ webadmin_user }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_bashrc') when:
- local_template_dir_webadmin.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_bashrc')
tags: tags:
- webadmin - webadmin
- bash - bash
@ -172,6 +187,8 @@
with_items: "{{ webadmin_user }}" with_items: "{{ webadmin_user }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.name }}'
when:
- local_template_dir_webadmin.stat.exists
tags: tags:
- webadmin - webadmin
- profile - profile
@ -181,7 +198,9 @@
with_items: "{{ profile_webadmin_orig_exists.results }}" with_items: "{{ profile_webadmin_orig_exists.results }}"
loop_control: loop_control:
label: '{{ item.item.name }}' label: '{{ item.item.name }}'
when: item.stat.exists == False when:
- local_template_dir_webadmin.stat.exists
- item.stat.exists == False
tags: tags:
- webadmin - webadmin
- profile - profile
@ -196,7 +215,9 @@
with_items: "{{ webadmin_user }}" with_items: "{{ webadmin_user }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_profile') when:
- local_template_dir_webadmin.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_profile')
tags: tags:
- webadmin - webadmin
- profile - profile
@ -215,7 +236,9 @@
with_items: "{{ webadmin_user }}" with_items: "{{ webadmin_user }}"
loop_control: loop_control:
label: '{{ item.name }}' label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc') when:
- local_template_dir_webadmin.stat.exists
- lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc')
tags: tags:
- webadmin - webadmin
- vim - vim