diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2021-12-07 15:41:02 +0000 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2021-12-07 20:24:51 +0000 |
commit | 9bd2c8c17a22c84da9a6ba6407c5b928d77fb469 (patch) | |
tree | e382576853ac2ebfeffcf3eda6e45f6ec9618656 /roles/vmm/tasks | |
parent | 12cf22b1a8d9ad23809ad8048119a6920cbb9675 (diff) | |
download | rules-9bd2c8c17a22c84da9a6ba6407c5b928d77fb469.tar.gz |
roles/vmm: Serve autoinstall configurations via httpd
Diffstat (limited to 'roles/vmm/tasks')
-rw-r--r-- | roles/vmm/tasks/autoinstall-configuration.yml | 27 | ||||
-rw-r--r-- | roles/vmm/tasks/disk.yml | 2 | ||||
-rw-r--r-- | roles/vmm/tasks/facts.yml | 8 | ||||
-rw-r--r-- | roles/vmm/tasks/main.yml | 34 | ||||
-rw-r--r-- | roles/vmm/tasks/network.yml | 27 |
5 files changed, 66 insertions, 32 deletions
diff --git a/roles/vmm/tasks/autoinstall-configuration.yml b/roles/vmm/tasks/autoinstall-configuration.yml new file mode 100644 index 0000000..e05b11c --- /dev/null +++ b/roles/vmm/tasks/autoinstall-configuration.yml @@ -0,0 +1,27 @@ +- name: include httpd role variables + include_vars: "{{ inventory_dir }}/roles/httpd/defaults/main.yml" + +- name: create autoinstall directory + file: + path: /var/www/htdocs/autoinstall + owner: www + group: www + mode: 0700 + state: directory + +- name: generate autoinstall files + template: + src: autoinstall.conf.j2 + dest: "/var/www/htdocs/autoinstall/{{ item.lladdr }}-install.conf" + owner: www + group: www + mode: 0640 + loop: "{{ vmm_vms }}" + +- name: generate httpd configuration + template: + src: httpd.conf.j2 + dest: "{{ httpd_configuration_dir }}/autoinstall.conf" + owner: 0 + group: 0 + mode: 0640 diff --git a/roles/vmm/tasks/disk.yml b/roles/vmm/tasks/disk.yml index 24dd491..423d855 100644 --- a/roles/vmm/tasks/disk.yml +++ b/roles/vmm/tasks/disk.yml @@ -2,7 +2,7 @@ command: cmd: vmctl create -s "{{ item.size }}" "{{ item.name }}.{{ vmm_disk_format }}" chdir: "{{ vmm_disk_dir }}" - loop: "{{ __vms }}" + loop: "{{ vmm_vms }}" register: result changed_when: result.rc == 0 failed_when: diff --git a/roles/vmm/tasks/facts.yml b/roles/vmm/tasks/facts.yml index 7cf4f0c..c7b453b 100644 --- a/roles/vmm/tasks/facts.yml +++ b/roles/vmm/tasks/facts.yml @@ -1,14 +1,14 @@ - name: generate lladdr variable for virtual machines set_fact: - tmp_vms: > - {{ tmp_vms | default([]) + [ item | combine({ + vmm_vms_tmp: > + {{ vmm_vms_tmp | default([]) + [ item | combine({ 'lladdr': item.name | hash('sha1') | truncate(12, True, '') | ansible.netcommon.hwaddr('unix') }) ] }} - loop: "{{ __vms }}" + loop: "{{ vmm_vms }}" - name: save variables set_fact: - __vms: "{{ tmp_vms }}" + vmm_vms: "{{ vmm_vms_tmp }}" diff --git a/roles/vmm/tasks/main.yml b/roles/vmm/tasks/main.yml index 3c5a462..c596664 100644 --- a/roles/vmm/tasks/main.yml +++ b/roles/vmm/tasks/main.yml @@ -13,6 +13,10 @@ - name: include facts generation include_tasks: facts.yml +- name: include autoinstall generation + include_tasks: autoinstall-configuration.yml + tags: task_autoinstall_configuration + - name: include iso management include_tasks: iso.yml tags: task_iso @@ -21,33 +25,9 @@ include_tasks: disk.yml tags: task_disk -- name: start ip forwarding - command: sysctl net.inet.ip{{ item }}.forwarding=1 - loop: "{{ vmm_network_forwarded_ips }}" - -- name: enable ip forwarding - lineinfile: - path: /etc/sysctl.conf - regexp: "^net.inet.ip{{ item }}.forwarding=" - line: "net.inet.ip{{ item }}.forwarding=1" - owner: 0 - group: 0 - mode: 0640 - create: true - loop: "{{ vmm_network_forwarded_ips }}" - -- name: create network switch - lineinfile: - path: "/etc/hostname.{{ vmm_network_switch.interface }}" - regexp: &network_line "add {{ ansible_default_ipv4.interface }}" - line: *network_line - owner: 0 - group: 0 - mode: 0640 - create: true - -- name: start network switch - command: "sh /etc/netstart {{ vmm_network_switch.interface }}" +- name: include network management + include_tasks: network.yml + tags: task_network - name: generate vmm configuration template: diff --git a/roles/vmm/tasks/network.yml b/roles/vmm/tasks/network.yml new file mode 100644 index 0000000..b8fc7e1 --- /dev/null +++ b/roles/vmm/tasks/network.yml @@ -0,0 +1,27 @@ +- name: start ip forwarding + command: sysctl net.inet.ip{{ item }}.forwarding=1 + loop: "{{ vmm_network_forwarded_ips }}" + +- name: enable ip forwarding + lineinfile: + path: /etc/sysctl.conf + regexp: "^net.inet.ip{{ item }}.forwarding=" + line: "net.inet.ip{{ item }}.forwarding=1" + owner: 0 + group: 0 + mode: 0640 + create: true + loop: "{{ vmm_network_forwarded_ips }}" + +- name: create network switch + lineinfile: + path: "/etc/hostname.{{ vmm_network_switch.interface }}" + regexp: &network_line "add {{ ansible_default_ipv4.interface }}" + line: *network_line + owner: 0 + group: 0 + mode: 0640 + create: true + +- name: start network switch + command: "sh /etc/netstart {{ vmm_network_switch.interface }}" |