Verified Commit 844deba6 authored by rlacko's avatar rlacko 💬
Browse files

Refactor everything

parent 3e4cdbd7
---
timezone: Europe/Budapest
na: "https://git.sch.bme.hu/kszk/sysadmin/kubernetes/base-ansible-role"
hostname: "{{ inventory_hostname }}"
netplan_config_file: 01-netcfg.yaml
motd_text: KSZK Host
# ssh:
# * Generic settings
base_timezone: Europe/Budapest
base_motd_playbook_url: "https://git.sch.bme.hu/kszk/ansible/roles/base"
base_hostname: "{{ inventory_hostname }}"
#base_motd_text: KSZK Host
## Template file locations
base_netplan_config_file: base-role/etc/netplan/01-netcfg.yaml.j2
base_ssh_config_file: base-role/etc/ssh/sshd_config.j2
base_additional_packages: []
# base_ssh:
# port: 10022
# pubkeyAuthentication: "yes"
# passwordAuthentication: "no"
......@@ -17,15 +24,15 @@ motd_text: KSZK Host
# enabled: False
# ipList: "192.168.42.0/24"
# users:
#- name: kszk
# comment: "kszk@sch.bme.hu" # optional
# sudo: yes
# passwordless_sudo: yes
# # https://docs.ansible.com/ansible/latest/collections/ansible/posix/authorized_key_module.html#examples
# ssh_key: https://git.sch.bme.hu/xy.keys
# base_users:
# - name: kszk
# comment: "kszk@sch.bme.hu" # optional
# sudo: yes
# passwordless_sudo: yes
# # https://docs.ansible.com/ansible/latest/collections/ansible/posix/authorized_key_module.html#examples
# ssh_key: https://git.sch.bme.hu/xy.keys
# netplan:
# base_netplan:
# network:
# ethernets:
# ens192:
......
galaxy_info:
author: kszk
description: Base role for Kubernetes VMs
description: Base role for VMs
company: KSZK
license: MIT
platforms:
......
......@@ -2,7 +2,7 @@
- name: Disable floppy module
template:
src: etc/modprobe.d/blacklist-floppy.conf.j2
src: base-role/etc/modprobe.d/blacklist-floppy.conf.j2
dest: /etc/modprobe.d/blacklist-floppy.conf
mode: 0644
register: blacklist_floppy
......
......@@ -2,9 +2,9 @@
# Dependent roles will be installed first
- name: Set hostname
when: hostname is defined
when: base_hostname is defined
hostname:
name: "{{ hostname }}"
name: "{{ base_hostname }}"
tags: [hostname]
- name: Upgrade packages
......@@ -13,8 +13,8 @@
- name: Setup admin users
include_tasks: setup_user.yml
when: users is defined
loop: "{{ users }}"
when: base_users is defined
loop: "{{ base_users }}"
loop_control:
loop_var: user
......@@ -23,21 +23,21 @@
tags: [packages]
- name: Setup Message of the day (MOTD)
when: motd_text is defined
import_tasks: "motd.yml"
when: base_motd_text is defined
import_tasks: motd.yml
tags: [motd]
- name: Setup SSH
when: ssh is defined
import_tasks: "ssh.yml"
when: base_ssh is defined
import_tasks: ssh.yml
tags: [ssh]
- name: Disable floppy
include_tasks: floppy.yaml
include_tasks: floppy.yml
- name: Fix multipath UUID VMWare errors
include_tasks: multipath.yaml
include_tasks: multipath.yml
- name: Update netplan config
when: netplan is defined
include_tasks: netplan.yaml
when: base_netplan is defined
include_tasks: netplan.yml
......@@ -6,7 +6,7 @@
- figlet
- name: Generate motd ascii from text
command: figlet {{ motd_text }}
command: figlet {{ base_motd_text }}
register: motd_ascii_art
changed_when: false
......@@ -15,11 +15,11 @@
path: "{{ item }}"
state: absent
with_items:
- /etc/update-motd.d/10-help-text
- /etc/update-motd.d/50-motd-news
- base-role/etc/update-motd.d/10-help-text
- base-role/etc/update-motd.d/50-motd-news
- name: Place motd file.
template:
src: etc/update-motd.d/motd.sh
src: base-role/etc/update-motd.d/motd.sh.j2
dest: /etc/update-motd.d/40-custom-banner
mode: 0755
......@@ -2,7 +2,7 @@
- name: Blacklist multipath in VMWare disks
template:
src: etc/multipath.conf.j2
src: base-role/etc/multipath.conf.j2
dest: /etc/multipath.conf
mode: 0644
register: blacklist_vmware_multipath
......
---
- name: Disable cloud init networking
template:
src: etc/cloud/cloud.cfg.d/99-disable-network-config.cfg.j2
src: base-role/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg.j2
dest: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
mode: 0644
- name: Add netplan network config
template:
src: etc/netplan/{{ netplan_config_file }}.j2
dest: /etc/netplan/{{ netplan_config_file }}
src: '{{ netplan_config_file }}'
dest: /etc/netplan/01-netcfg.yaml
mode: 0644
register: netplan_config
......
......@@ -36,3 +36,8 @@
- curl
- wget
- jq
- name: Install additional packages
package:
state: present
name: '{{ base_additional_packages }}'
---
- debug:
- name: Print current user
debug:
msg: "{{ user }}"
- name: "Create group for user"
......@@ -23,7 +24,7 @@
- name: Insert sudoer file content
template:
src: etc/sudoers.d/user.j2
src: base-role/etc/sudoers.d/user.j2
dest: /etc/sudoers.d/{{ user.name }}
mode: 0600
owner: root
......
---
- name: Place sshd configuration file.
template:
src: etc/ssh/sshd_config
src: '{{ base_ssh_config_file }}'
dest: /etc/ssh/sshd_config
mode: 0600
register: sshd_config
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment