Reduce output from ansible playbooks. Some minor changes.

This commit is contained in:
2019-07-03 04:14:14 +02:00
parent 21fcd86115
commit 505cdbf120
25 changed files with 3158 additions and 615 deletions

View File

@ -104,7 +104,7 @@
state: "{{ apt_install_state }}"
when: apt_install_lxc_host_pkgs|bool
tags:
- apt-lxc-hosts-pkgs|bool
- apt-lxc-hosts-pkgs
- name: (apt.yml) Install compiler related packages
apt:
@ -112,7 +112,7 @@
state: "{{ apt_install_state }}"
when: apt_install_compiler_pkgs|bool
tags:
- apt-compiler-pkgs|bool
- apt-compiler-pkgs
- name: (apt.yml) Install postgresql_server related packages
apt:

View File

@ -0,0 +1,11 @@
---
- hosts: o25.oopen.de
tasks:
- name: Ensure aptitude is present
raw: test -e /usr/bin/aptitude || apt-get install aptitude -y
- name: Ensure python2 is present (This is necessary for ansible to work properly)
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)

View File

@ -1,28 +1,41 @@
---
- name: (git.yml) include variables
include_vars: "{{ item }}"
with_first_found:
- "git-{{ inventory_hostname }}.yml"
- "git-{{ ansible_distribution_release }}.yml"
- "git-{{ ansible_distribution | lower }}.yml"
- git-default.yml
tags:
- git-default-repositories
- git-lxc-guest-repositories
- git-apache2-repositories
- git-nginx-repositories
- git-mysql-server-repositories
- git-postgresql-server-repositories
- git-nextcloud-server-repositories
- git-dns-server-repositories
- git-backup-server-repositories
- git-samba-server-repositories
- git-mailservers-repositories
- git-sympa-repositories
- git-other-repositories
#- name: (git.yml) include variables
# include_vars: "{{ item }}"
# with_first_found:
# - "git-{{ inventory_hostname }}.yml"
# - "git-{{ ansible_distribution_release }}.yml"
# - "git-{{ ansible_distribution | lower }}.yml"
# - git-default.yml
# tags:
# - git-default-repositories
# - git-lxc-guest-repositories
# - git-apache2-repositories
# - git-nginx-repositories
# - git-mysql-server-repositories
# - git-postgresql-server-repositories
# - git-nextcloud-server-repositories
# - git-dns-server-repositories
# - git-backup-server-repositories
# - git-samba-server-repositories
# - git-mailservers-repositories
# - git-sympa-repositories
# - git-other-repositories
# ---
# Firewall repository
# ---
- name: (git.yml) Install/Update firewall repository
git:
repo: "{{ git_firewall_repository.repo}}"
dest: "{{ git_firewall_repository.dest }}"
when: git_firewall_repository is defined and git_firewall_repository > 0
tags:
- git-firewall-repository
# ---
# Default reposotories
# ---
@ -32,6 +45,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_default_repositories }}'
loop_control:
label: "{{ item.name }}"
tags:
- git-default-repositories
@ -45,6 +60,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_lxc_guest_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['lxc_guest']|string is search(inventory_hostname)"
tags:
- git-lxc-guest-repositories
@ -59,11 +76,29 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_lxc_host_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['lxc_host']|string is search(inventory_hostname)"
tags:
- git-lxc-host-repositories
# ---
# Group [gateway_server] reposotories
# ---
- name: (git.yml) Install/Update gateway repositories
git:
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_gateway_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['gateway_server']|string is search(inventory_hostname)"
tags:
- git-gateway-server-repositories
# ---
# Group [apache2_webserver] reposotories
# ---
@ -73,6 +108,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_apache2_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['apache2_webserver']|string is search(inventory_hostname)"
tags:
- git-apache2-repositories
@ -87,6 +124,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_nginx_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['nginx_webserver']|string is search(inventory_hostname)"
tags:
- git-nginx-repositories
@ -101,6 +140,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_mysql_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['mysql_server']|string is search(inventory_hostname)"
tags:
- git-mysql-server-repositories
@ -115,6 +156,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_postgresql_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['postgresql_server']|string is search(inventory_hostname)"
tags:
- git-postgresql-server-repositories
@ -129,6 +172,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_nextcloud_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['nextcloud_server']|string is search(inventory_hostname)"
tags:
- git-nextcloud-server-repositories
@ -143,6 +188,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_dns_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['dns_server']|string is search(inventory_hostname)"
tags:
- git-dns-server-repositories
@ -157,6 +204,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_backup_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['backup_server']|string is search(inventory_hostname)"
ignore_errors: True
tags:
@ -172,6 +221,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_samba_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['samba_server']|string is search(inventory_hostname)"
ignore_errors: True
tags:
@ -183,18 +234,13 @@
# Group [mail_server] reposotories
# ---
#- name: include variables
# include_vars: "git-mailservers.yml"
# tags:
# - initial-setup
# - git
# - git-mailservers
- name: (git.yml) Install/Update default repositories
- name: (git.yml) Install/Update mail server repositories
git:
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_mailserver_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['mail_server']|string is search(inventory_hostname)"
tags:
- git-mailservers-repositories
@ -209,6 +255,8 @@
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
with_items: '{{ git_sympa_repositories }}'
loop_control:
label: "{{ item.name }}"
when: "groups['sympa_list_server']|string is search(inventory_hostname)"
tags:
- git-sympa-repositories
@ -232,6 +280,8 @@
git:
repo: '{{ item.repo }}'
dest: '{{ item.dest }}'
loop_control:
label: "{{ item.name }}"
with_items: '{{ git_other_repositories }}'
tags:
- git-other-repositories

View File

@ -86,8 +86,11 @@
# tags supportetd inside git.yml
#
# git-firewall-repository
# git-default-repositories
# git-lxc-host-repositories
# git-lxc-guest-repositories
# git-gateway-server-repositories
# git-apache2-repositories
# git-nginx-repositories
# git-mysql-server-repositories

View File

@ -1,16 +1,16 @@
---
- name: (sudoers.yml) include variables
include_vars: "{{ item }}"
with_first_found:
- "sudoers-{{ inventory_hostname }}.yml"
- "sudoers-{{ ansible_distribution_release }}.yml"
- "sudoers-{{ ansible_distribution | lower }}.yml"
- "sudoers-default.yml"
tags:
- sudoers-remove
- sudoers-file-configuration
- sudoers-global-configuration
#- name: (sudoers.yml) include variables
# include_vars: "{{ item }}"
# with_first_found:
# - "sudoers-{{ inventory_hostname }}.yml"
# - "sudoers-{{ ansible_distribution_release }}.yml"
# - "sudoers-{{ ansible_distribution | lower }}.yml"
# - "sudoers-default.yml"
# tags:
# - sudoers-remove
# - sudoers-file-configuration
# - sudoers-global-configuration
- name: (sudoers.yml) Remove user entries in file /etc/sudoers
lineinfile:

View File

@ -8,13 +8,18 @@
stat:
path: "~{{ item.name }}/.bashrc.ORIG"
register: bashrc_user_orig_exists
with_items: "{{ default_user }}"
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
tags:
- bash
- name: (users-systemfiles.yml) Backup existing users .bashrc file
command: cp ~{{ item.item.name }}/.bashrc ~{{ item.item.name }}/.bashrc.ORIG
with_items: "{{ bashrc_user_orig_exists.results }}"
loop: "{{ bashrc_user_orig_exists.results }}"
loop_control:
label: '{{ item.item.name }}'
#with_items: "{{ bashrc_user_orig_exists.results }}"
when: item.stat.exists == False
tags:
- bash
@ -26,7 +31,9 @@
owner: "{{ item.name }}"
group: "{{ item.name }}"
mode: 0644
with_items: "{{ default_user }}"
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_bashrc')
tags:
- bash
@ -63,13 +70,17 @@
stat:
path: "~{{ item.name }}/.profile.ORIG"
register: profile_user_orig_exists
with_items: "{{ default_user }}"
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
tags:
- profile
- name: (users-systemfiles.yml) Backup existing users .profile file
command: cp ~{{ item.item.name }}/.profile ~{{ item.item.name }}/.profile.ORIG
with_items: "{{ profile_user_orig_exists.results }}"
loop: "{{ profile_user_orig_exists.results }}"
loop_control:
label: '{{ item.item.name }}'
when: item.stat.exists == False
tags:
- profile
@ -81,7 +92,9 @@
owner: "{{ item.name }}"
group: "{{ item.name }}"
mode: 0644
with_items: "{{ default_user }}"
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_profile')
tags:
- profile
@ -121,7 +134,9 @@
owner: "{{ item.name }}"
group: "{{ item.name }}"
mode: 0644
with_items: "{{ default_user }}"
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc')
tags:
- vim

View File

@ -9,7 +9,9 @@
name: '{{ item.name }}'
state: present
gid: '{{ item.group_id | default(omit) }}'
with_items: '{{ default_user }}'
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
when: item.group_id is defined
tags:
- groups-exists
@ -24,7 +26,9 @@
shell: '{{ item.shell|d("/bin/bash") }}'
password: "{{ item.password }}"
update_password: on_create
with_items: '{{ default_user }}'
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
tags:
- users-exists
@ -36,6 +40,8 @@
with_subelements:
- '{{ default_user }}'
- ssh_keys
loop_control:
label: "{{ item.0.name }}"
tags:
- authorized_key
@ -48,7 +54,9 @@
name: '{{ item.name }}'
state: present
gid: '{{ item.group_id | default(omit) }}'
with_items: '{{ extra_user }}'
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
when:
- extra_user is defined and extra_user|length > 0
- item.group_id is defined
@ -65,7 +73,9 @@
shell: '{{ item.shell|d("/bin/bash") }}'
password: "{{ item.password }}"
update_password: on_create
with_items: '{{ extra_user }}'
loop: "{{ default_user }}"
loop_control:
label: '{{ item.name }}'
when: extra_user is defined and extra_user|length > 0
tags:
- users-exists
@ -78,6 +88,8 @@
with_subelements:
- '{{ extra_user }}'
- ssh_keys
loop_control:
label: "{{ item.0.name }}"
when: extra_user is defined and extra_user|length > 0
tags:
- authorized_key
@ -87,14 +99,16 @@
# - Take care backup host has rsa key to connect via ssh to the other hosts
# ---
- name: (users.yml) Copy ssh rsa private key to user root of backup server
- name: (users.yml) Copy ssh rsa private key to user root on backup server
copy:
src: '{{ item.priv_key_src }}'
dest: '{{ item.priv_key_dest }}'
owner: root
group: root
mode: '0600'
with_items: '{{ ssh_keypair_backup_server }}'
loop: "{{ ssh_keypair_backup_server }}"
loop_control:
label: '{{ item.priv_key_dest }}'
when:
- ssh_keypair_backup_server is defined and ssh_keypair_backup_server|length > 0
- insert_ssh_keypair_backup_server|bool
@ -103,14 +117,16 @@
- keypair-backup-server
- name: (users.yml) Copy ssh rsa public key to user root of backup server
- name: (users.yml) Copy ssh rsa public key to user root on backup server
copy:
src: '{{ item.pub_key_src }}'
dest: '{{ item.pub_key_dest }}'
owner: root
group: root
mode: '0644'
with_items: '{{ ssh_keypair_backup_server }}'
loop: "{{ ssh_keypair_backup_server }}"
loop_control:
label: '{{ item.pub_key_dest }}'
when:
- ssh_keypair_backup_server is defined and ssh_keypair_backup_server|length > 0
- insert_ssh_keypair_backup_server|bool
@ -124,7 +140,9 @@
user: "{{ item.backup_user }}"
key: "{{ lookup('file', item.pub_key_src) }}"
state: present
with_items: '{{ ssh_keypair_backup_server }}'
loop: "{{ ssh_keypair_backup_server }}"
loop_control:
label: 'authorized_keys - user: {{ item.backup_user }}'
when: ssh_keypair_backup_server is defined and ssh_keypair_backup_server|length > 0
tags:
- authorized_key
@ -146,7 +164,10 @@
when:
- insert_root_ssh_keypair|bool
- groups['backup_server']|string is not search(inventory_hostname)
with_items: '{{ root_ssh_keypair }}'
loop: "{{ root_ssh_keypair }}"
loop_control:
label: 'dest: {{ item.priv_key_dest }}'
#with_items: '{{ root_ssh_keypair }}'
tags:
- insert_root_ssh_keypair
- root-defaut-ssh-keypair
@ -158,8 +179,10 @@
owner: root
group: root
mode: '0644'
with_items: '{{ root_ssh_keypair }}'
#when: groups['oopen_server']|string is search(inventory_hostname)
loop: "{{ root_ssh_keypair }}"
loop_control:
label: 'dest: {{ item.pub_key_dest }}'
#with_items: '{{ root_ssh_keypair }}'
when:
- insert_root_ssh_keypair|bool
- groups['backup_server']|string is not search(inventory_hostname)
@ -172,7 +195,10 @@
user: root
key: "{{ lookup('file', item.pub_key_src) }}"
state: present
with_items: '{{ root_ssh_keypair }}'
loop: "{{ root_ssh_keypair }}"
loop_control:
label: 'authorized_keys - user: root'
#with_items: '{{ root_ssh_keypair }}'
when: inventory_hostname == item.target
tags:
- authorized_key

View File

@ -10,6 +10,8 @@
state: present
gid: '{{ item.group_id | default(omit) }}'
with_items: '{{ webadmin_user }}'
loop_control:
label: "{{ item.name }}"
when:
- groups['webadmin']|string is search(inventory_hostname)
- webadmin_user is defined
@ -29,6 +31,8 @@
password: "{{ item.password }}"
update_password: on_create
with_items: '{{ webadmin_user }}'
loop_control:
label: "{{ item.name }}"
when:
- groups['webadmin']|string is search(inventory_hostname)
- webadmin_user is defined
@ -44,6 +48,8 @@
with_subelements:
- '{{ webadmin_user }}'
- ssh_keys
loop_control:
label: "{{ item.0.name }}"
when:
- groups['webadmin']|string is search(inventory_hostname)
- webadmin_user is defined
@ -62,6 +68,8 @@
when:
- insert_webadmin_ssh_keypair|bool
with_items: '{{ webadmin_ssh_keypair }}'
loop_control:
label: 'dest: {{ item.priv_key_dest }}'
tags:
- webadmin
- webadmin-defaut-ssh-keypair
@ -74,6 +82,8 @@
group: '{{ item.login }}'
mode: '0644'
with_items: '{{ webadmin_ssh_keypair }}'
loop_control:
label: 'dest: {{ item.pub_key_dest }}'
when:
- insert_webadmin_ssh_keypair|bool
tags:
@ -102,6 +112,8 @@
key: "{{ lookup('file', item.pub_key_src) }}"
state: present
with_items: '{{ webadmin_ssh_keypair }}'
loop_control:
label: 'authorized_keys - webadmin: root'
when: inventory_hostname == item.target
tags:
- webadmin
@ -118,6 +130,8 @@
path: "~{{ item.name }}/.bashrc.ORIG"
register: bashrc_webadmin_orig_exists
with_items: "{{ webadmin_user }}"
loop_control:
label: '{{ item.name }}'
tags:
- webadmin
- bash
@ -125,6 +139,8 @@
- name: (webadmin-user.yml) Backup existing webadmin's .bashrc file
command: cp ~{{ item.item.name }}/.bashrc ~{{ item.item.name }}/.bashrc.ORIG
with_items: "{{ bashrc_webadmin_orig_exists.results }}"
loop_control:
label: '{{ item.item.name }}'
when: item.stat.exists == False
tags:
- webadmin
@ -138,6 +154,8 @@
group: "{{ item.name }}"
mode: 0644
with_items: "{{ webadmin_user }}"
loop_control:
label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_bashrc')
tags:
- webadmin
@ -152,6 +170,8 @@
path: "~{{ item.name }}/.profile.ORIG"
register: profile_webadmin_orig_exists
with_items: "{{ webadmin_user }}"
loop_control:
label: '{{ item.name }}'
tags:
- webadmin
- profile
@ -159,6 +179,8 @@
- name: (webadmin-user.yml) Backup existing users .profile file
command: cp ~{{ item.item.name }}/.profile ~{{ item.item.name }}/.profile.ORIG
with_items: "{{ profile_webadmin_orig_exists.results }}"
loop_control:
label: '{{ item.item.name }}'
when: item.stat.exists == False
tags:
- webadmin
@ -172,6 +194,8 @@
group: "{{ item.name }}"
mode: 0644
with_items: "{{ webadmin_user }}"
loop_control:
label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_profile')
tags:
- webadmin
@ -189,6 +213,8 @@
group: "{{ item.name }}"
mode: 0644
with_items: "{{ webadmin_user }}"
loop_control:
label: '{{ item.name }}'
when: lookup('fileglob', inventory_dir + '/files/homedirs/' + item.name + '/_vimrc')
tags:
- webadmin