first commit

This commit is contained in:
Nils Cant
2020-05-05 17:29:21 +02:00
commit 9f15fde015
8 changed files with 131 additions and 0 deletions

8
README.md Normal file
View File

@@ -0,0 +1,8 @@
#
```
cd /var/www/html
curl -O https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.3/4.3.0/rhcos-4.3.0-x86_64-metal.raw.gz
curl -O https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.3/4.3.0/rhcos-4.3.0-x86_64-installer-kernel
curl -O https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.3/4.3.0/rhcos-4.3.0-x86_64-installer-initramfs.img
```

9
defaults/main.yml Normal file
View File

@@ -0,0 +1,9 @@
os4_pxe_install_server_address: ""
os4_pxe_install_server_gateway: ""
os4_pxe_install_server_netmask: ""
os4_pxe_install_server_domain_name: ""
os4_pxe_install_server_nameserver: ""
os4_pxe_install_server_clients: []
os4_pxe_install_server_firewalld_configure: yes
os4_pxe_install_server_firewalld_zone: public
os4_pxe_install_server_httpd_port: 80

4
handlers/main.yml Normal file
View File

@@ -0,0 +1,4 @@
- name: Restart dhcpd
service:
name: dhcpd
state: restarted

17
tasks/firewalld.yml Normal file
View File

@@ -0,0 +1,17 @@
- name: Ensure firewalld is enabled
service:
name: firewalld
enabled: true
state: started
- name: Open firewalld ports
firewalld:
port: "{{ item }}"
state: enabled
zone: "{{ os4_pxe_install_server_firewalld_zone }}"
immediate: yes
permanent: yes
loop:
- "{{ os4_pxe_install_server_httpd_port }}/tcp"
- "69/tcp"
- "69/udp"

54
tasks/main.yml Normal file
View File

@@ -0,0 +1,54 @@
- name: Install packages
yum:
name: ["dhcp-server", "syslinux", "tftp", "tftp-server", "xinetd", "httpd"]
- name: dhcpd configuration
template:
src: dhcpd.conf.j2
dest: /etc/dhcp/dhcpd.conf
notify: Restart dhcpd
- name: tftp configuration
template:
src: tftp.j2
dest: /etc/xinetd.d/tftp
- name: tftpboot directory
file:
name: /var/lib/tftpboot/pxelinux.cfg
state: directory
- name: syslinux files
file:
state: hard
src: "/usr/share/syslinux/{{ item }}"
dest: "/var/lib/tftpboot/{{ item }}"
loop: ["pxelinux.0", "ldlinux.c32"]
- name: tftpboot configuration
template:
src: pxelinux.cfg-default.j2
dest: "/var/lib/tftpboot/pxelinux.cfg/{{ item.ip | ip4_hex | upper}}"
loop: "{{ os4_pxe_install_server_clients }}"
- name: dhcpd service
service:
name: dhcpd
state: started
enabled: yes
- name: httpd service
service:
name: httpd
state: started
enabled: yes
- name: xinetd service
service:
name: xinetd
state: started
enabled: yes
- name: Configure firewalld
import_tasks: firewalld.yml
when: os4_pxe_install_server_firewalld_configure

20
templates/dhcpd.conf.j2 Normal file
View File

@@ -0,0 +1,20 @@
subnet {{ os4_pxe_install_server_address | ipaddr('network') }} netmask {{ os4_pxe_install_server_address | ipaddr('netmask') }} {
option domain-name-servers {{ os4_pxe_install_server_nameserver }};
option domain-name "ocp01.lab.vargen.io";
option routers {{ os4_pxe_install_server_gateway }};
option broadcast-address {{ os4_pxe_install_server_address | ipaddr('broadcast') }};
next-server {{ os4_pxe_install_server_address | ipaddr('address') }};
filename "pxelinux.0";
{% for host in os4_pxe_install_server_clients -%}
host {{ host.hostname }} {
hardware ethernet {{ host.mac | upper }};
option host-name "{{ host.hostname }}";
fixed-address {{ host.ip }};
}
{% endfor %}
}

View File

@@ -0,0 +1,6 @@
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
KERNEL http://{{ os4_pxe_install_server_address | ipaddr('address') }}:{{ os4_pxe_install_server_httpd_port }}/rhcos-4.3.0-x86_64-installer-kernel
APPEND ip=dhcp rd.neednet=1 initrd=http://{{ os4_pxe_install_server_address | ipaddr('address') }}:{{ os4_pxe_install_server_httpd_port }}/rhcos-4.3.0-x86_64-installer-initramfs.img console=tty0 console=ttyS0 coreos.inst=yes coreos.inst.install_dev=vda coreos.inst.image_url=http://{{ os4_pxe_install_server_address | ipaddr('address') }}:{{ os4_pxe_install_server_httpd_port }}/rhcos-4.3.0-x86_64-metal.raw.gz coreos.inst.ignition_url=http://{{ os4_pxe_install_server_address | ipaddr('address') }}:{{ os4_pxe_install_server_httpd_port }}/{{ item.ignition }}

13
templates/tftp.j2 Normal file
View File

@@ -0,0 +1,13 @@
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}