Restructure pxe server role files and templates

This commit is contained in:
Khue Doan 2021-08-30 23:44:25 +07:00
parent f42eb4c54d
commit 32b86b6c68
8 changed files with 22 additions and 105 deletions

View File

@ -0,0 +1,21 @@
version: "3"
services:
dhcp:
build: ./dhcp
volumes:
- ./dhcp/dhcpd.conf:/etc/dhcp/dhcpd.conf
network_mode: host
tftp:
build: ./tftp
network_mode: host
volumes:
- ./tftp/grub.cfg:/var/lib/tftpboot/grub.cfg
http:
build: ./http
network_mode: host
volumes:
- ./data/iso:/usr/share/nginx/html/iso
- ./data/init-config/:/usr/share/nginx/html/init-config
environment:
NGINX_PORT: 80

View File

@ -1,25 +0,0 @@
version: "3"
services:
dhcp:
build: ./dhcp
volumes:
- ./dhcp/dhcpd.conf:/etc/dhcp/dhcpd.conf
network_mode: host
tftp:
build: ./tftp
network_mode: host
volumes:
- ./tftp/tftpboot/grub.cfg:/var/lib/tftpboot/grub.cfg
- ./mnt/EFI/fedora/grubx64.efi:/var/lib/tftpboot/grubx64.efi
- ./mnt/images/ignition.img:/var/lib/tftpboot/ignition.img
- ./mnt/images/pxeboot/initrd.img:/var/lib/tftpboot/initrd.img
- ./mnt/images/pxeboot/vmlinuz:/var/lib/tftpboot/vmlinuz
http:
build: ./http
network_mode: host
volumes:
- ./mnt:/usr/share/nginx/html/CoreOS
- ./http/ignition/:/usr/share/nginx/html/ignition
environment:
NGINX_PORT: 80

View File

@ -1,6 +1,6 @@
set timeout=1
menuentry '{{ os_name }} (Live)' {
menuentry '{{ iso_url | basename | splitext | first }} (PXE)' {
linux vmlinuz \
ip=dhcp \
ignition.platform.id=metal \

View File

@ -1,79 +0,0 @@
variant: fcos
version: 1.3.0
passwd:
users:
- name: root
ssh_authorized_keys:
- {{ ssh_public_key }}
storage:
files:
# Set hostname
- path: /etc/hostname
mode: 0644
contents:
inline: {{ hostvars[item]['inventory_hostname'] }}
# Set static IP
- path: /etc/NetworkManager/system-connections/{{ network_interface }}.nmconnection
mode: 0600
contents:
inline: |
[connection]
id={{ network_interface }}
type=ethernet
interface-name={{ network_interface }}
permissions=
[ipv4]
address1={{ (hostvars[item]['ansible_host'] + '/' + ansible_default_ipv4.netmask) | ansible.netcommon.ipaddr('host/prefix') }},{{ ansible_default_ipv4.gateway }}
dns={{ dns_server }};
dns-search=
method=manual
# Make audit logs less verbose
- path: /etc/sysctl.d/20-silence-audit.conf
contents:
inline: |
kernel.printk=4
# Fix flannel support
- path: /etc/systemd/network/50-flannel.link
contents:
inline: |
[Match]
OriginalName=flannel*
[Link]
MACAddressPolicy=none
links:
# Set timezone
- path: /etc/localtime
target: /usr/share/zoneinfo/{{ timezone }}
systemd:
units:
# iSCSI for Longhorn distributed block storage
- name: iscsid.service
enabled: true
{% if item == "metal0" %}
# Terraform state backend
- name: tfstate.service
enabled: true
contents: |
[Unit]
Description=Run etcd for Terraform state backend
After=network-online.target
Wants=network-online.target
[Service]
ExecStartPre=-/usr/bin/docker kill tfstate
ExecStartPre=-/usr/bin/docker rm tfstate
ExecStart=/usr/bin/docker run --name tfstate \
--volume tfstate:/bitnami/etcd/data \
--env ALLOW_NONE_AUTHENTICATION=yes \
--publish 23799:2379 \
--restart always \
bitnami/etcd
ExecStop=/usr/bin/docker stop tfstate
Restart=always
[Install]
WantedBy=multi-user.target
{% endif %}