Split init config to a separate role

This commit is contained in:
Khue Doan 2021-08-30 23:47:16 +07:00
parent 32b86b6c68
commit 25de291c71
4 changed files with 54 additions and 22 deletions

View File

@ -0,0 +1 @@
timezone: Asia/Ho_Chi_Minh

View File

@ -0,0 +1,4 @@
- name: Render machine specific init config
template:
src: kickstart.ks.j2
dest: "{{ playbook_dir }}/build/data/init-config/{{ hostvars[item]['mac'] }}.ks"

View File

@ -0,0 +1,49 @@
#version=DEVEL
# Do not use graphical install
text
# Keyboard layouts
keyboard --xlayouts='us'
# System language
lang en_US.UTF-8
# Partition clearing information
clearpart --all --drives={{ disk }}
# Partitioning
ignoredisk --only-use={{ disk }}
autopart
# Network information
network --bootproto=static --device={{ network_interface }} --ip={{ hostvars[item]['ansible_host'] }} --gateway={{ ansible_default_ipv4.gateway }} --nameserver={{ dns_server }} --netmask={{ ansible_default_ipv4.netmask }} --ipv6=auto --hostname={{ hostvars[item]['inventory_hostname'] }} --activate
# Use network installation
url --url="http://{{ ansible_default_ipv4.address }}/iso/"
# Disable Setup Agent on first boot
firstboot --disable
# Do not configure the X Window System
skipx
# System services
services --enabled="chronyd"
# System timezone
timezone {{ timezone }} --utc
# Create user (locked by default)
user --groups=wheel --name={{ os_username }}
# Add SSH key
sshkey --username=root "{{ ssh_public_key }}"
# SELinux
selinux --disabled
# Firewall
firewall --disabled
%packages
@^server-product-environment
%end
# Enable some services for Kubernetes
services --enable=iscsid
reboot

View File

@ -46,28 +46,6 @@
src: tftp/tftpboot/grub.cfg.j2
dest: "{{ role_path }}/build/tftp/tftpboot/grub.cfg"
- name: Render machine specific Butane config
template:
src: http/ignition/ignition.yaml.j2
dest: "{{ role_path }}/build/http/ignition/{{ hostvars[item]['mac'] }}.yaml"
loop: "{{ groups['metal'] }}"
- name: Render Ignition config from Butane config
docker_container:
name: butane
image: quay.io/coreos/butane:release
auto_remove: yes
volumes:
- "{{ role_path }}/build/http/ignition:/local/src"
working_dir: /local/src
command:
- --pretty
- --strict
- "{{ hostvars[item]['mac'] }}.yaml"
- --output
- "{{ hostvars[item]['mac'] }}.json"
loop: "{{ groups['metal'] }}"
- name: Start ephemeral PXE server
docker_compose:
project_src: "{{ role_path }}/build"