From 7bb88aaa661dc6756e862562c47368de11657f44 Mon Sep 17 00:00:00 2001 From: Georg Date: Wed, 5 Jan 2022 23:59:13 +0100 Subject: Init Ansible NetBox DHCP POC deployment Signed-off-by: Georg --- ansible/deployment_poc/README.md | 1 + ansible/deployment_poc/flow.svg | 321 +++++++++++++++++++++ ansible/deployment_poc/playbooks/deploy.yml | 104 +++++++ ansible/deployment_poc/tasks/configure_dhcp.yml | 31 ++ ansible/deployment_poc/tasks/configure_libvirt.yml | 61 ++++ ansible/deployment_poc/tasks/init_dhcp.yml | 7 + .../tasks/netbox_evaluate_cluster.yml | 50 ++++ .../deployment_poc/tasks/netbox_evaluate_ip.yml | 5 + .../tasks/netbox_evaluate_prefix.yml | 6 + .../deployment_poc/tasks/netbox_evaluate_site.yml | 5 + .../deployment_poc/tasks/netbox_evaluate_vm.yml | 23 ++ .../deployment_poc/tasks/netbox_query_cluster.yml | 14 + ansible/deployment_poc/tasks/netbox_query_ip.yml | 14 + .../deployment_poc/tasks/netbox_query_prefix.yml | 14 + ansible/deployment_poc/tasks/netbox_query_site.yml | 14 + ansible/deployment_poc/tasks/netbox_query_vm.yml | 15 + ansible/deployment_poc/tasks/netbox_tags_post.yml | 24 ++ ansible/deployment_poc/tasks/netbox_tags_pre.yml | 34 +++ ansible/deployment_poc/templates/dhcpd.conf.j2 | 5 + .../templates/libvirt-storage-template.xml.j2 | 16 + .../templates/libvirt-template.xml.j2 | 174 +++++++++++ .../deployment_poc/variables/deploy-variables.yml | 8 + 22 files changed, 946 insertions(+) create mode 100644 ansible/deployment_poc/README.md create mode 100644 ansible/deployment_poc/flow.svg create mode 100644 ansible/deployment_poc/playbooks/deploy.yml create mode 100644 ansible/deployment_poc/tasks/configure_dhcp.yml create mode 100644 ansible/deployment_poc/tasks/configure_libvirt.yml create mode 100644 ansible/deployment_poc/tasks/init_dhcp.yml create mode 100644 ansible/deployment_poc/tasks/netbox_evaluate_cluster.yml create mode 100644 ansible/deployment_poc/tasks/netbox_evaluate_ip.yml create mode 100644 ansible/deployment_poc/tasks/netbox_evaluate_prefix.yml create mode 100644 ansible/deployment_poc/tasks/netbox_evaluate_site.yml create mode 100644 ansible/deployment_poc/tasks/netbox_evaluate_vm.yml create mode 100644 ansible/deployment_poc/tasks/netbox_query_cluster.yml create mode 100644 ansible/deployment_poc/tasks/netbox_query_ip.yml create mode 100644 ansible/deployment_poc/tasks/netbox_query_prefix.yml create mode 100644 ansible/deployment_poc/tasks/netbox_query_site.yml create mode 100644 ansible/deployment_poc/tasks/netbox_query_vm.yml create mode 100644 ansible/deployment_poc/tasks/netbox_tags_post.yml create mode 100644 ansible/deployment_poc/tasks/netbox_tags_pre.yml create mode 100644 ansible/deployment_poc/templates/dhcpd.conf.j2 create mode 100644 ansible/deployment_poc/templates/libvirt-storage-template.xml.j2 create mode 100644 ansible/deployment_poc/templates/libvirt-template.xml.j2 create mode 100644 ansible/deployment_poc/variables/deploy-variables.yml (limited to 'ansible/deployment_poc') diff --git a/ansible/deployment_poc/README.md b/ansible/deployment_poc/README.md new file mode 100644 index 0000000..bfdd87e --- /dev/null +++ b/ansible/deployment_poc/README.md @@ -0,0 +1 @@ +![Flowchart about the deployment and provisioning process](flow.svg) diff --git a/ansible/deployment_poc/flow.svg b/ansible/deployment_poc/flow.svg new file mode 100644 index 0000000..d791ff2 --- /dev/null +++ b/ansible/deployment_poc/flow.svg @@ -0,0 +1,321 @@ + + + + + + + + START + + "User decides to provision a new virtual machine" + + + + + + + NetBox + (User) + + 1. User creates a "Virtual Machine" object + and enters the desired specifications + + + + + + + + + + + + Webhook + + 3. HTTPS POST is received and body data is parsed + + + + + + + NetBox + (System) + + 2. System creates a JSON object + and sends it out via HTTPS POST + + + + + + + YES + + Wehook + (System) + + 4. A shell script is executed, initiating + a SSH session + + + + + + + Does the received object contain valid JSON + with the required attributes? + + + + + + + Does the created object contain + the requireed fields? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Ansible + (System) + + 5. A playbook is executed + + + + + + + + + + + + + NetBox + (System) + + 6. The Virtual Machine object is queried + + + + + + + + + + + + Does the Virtual Machine object contain the required + fields, is it in the correct state and + compliant?l + + + + + + + + + + + + NO + + (System) + + Received data is discarded, and the process is aborted + + + + + + + + + + + + Ansible + (System) + + 7. A virtual hard disk is created + he actual virtual machine is defined + + + + + + + Ansible + (System) + + 8. The virtual machine is started + + + + + + + Libvirt + (System) + + 9. The virtual machine is network booted + + + + + + + + + The DHCP/TFTP/NFS process + loads a network operating system + + + + + + + OpenSUSE + (System) + + 11. The installer initializes the disk + + + + + + + + + + + + + + + + + + + + + + OpenSUSE + (System) + + 10. Requested oftware specifications + are collected + + + + + + + + + + + + + + + + + OpenSUSE + (System) + + 12. The operating system is installed + + + + + + + + + + + + + + + + + + + + + + OpenSUSE + (System) + + 13. The system starts base daemons + and sends a report via emaill + + + + + + + + + + + + END + + Pipeline completed + + + + + + + + + + + + + diff --git a/ansible/deployment_poc/playbooks/deploy.yml b/ansible/deployment_poc/playbooks/deploy.yml new file mode 100644 index 0000000..858ed00 --- /dev/null +++ b/ansible/deployment_poc/playbooks/deploy.yml @@ -0,0 +1,104 @@ +--- +- hosts: status_planned + gather_facts: no + vars: + token: "{{ nb_token }}" + vm_name: "{{ inventory_hostname }}" + tag_merged: [] + debug_merged: [] + vars_files: + - ../variables/deploy-variables.yml + + pre_tasks: + - name: Check lock + wait_for: + path: "{{ lockfile }}" + state: absent + timeout: 600 + msg: Lock did not disappear in time + delegate_to: localhost + + - name: Create lock + file: + path: "{{ lockfile }}" + state: touch + delegate_to: localhost + + tasks: + - name: Pipeline + block: + - name: Gather details + block: + - import_tasks: "../tasks/netbox_query_vm.yml" + - import_tasks: "../tasks/netbox_query_cluster.yml" + no_log: true + + - name: Assign variables + block: + - import_tasks: "../tasks/netbox_evaluate_cluster.yml" + - import_tasks: "../tasks/netbox_evaluate_vm.yml" + + - name: Verify compliance + block: + - name: Check status + fail: + msg: The object is not Planned. + when: status != 'planned' + + - name: Check tag + fail: + msg: The object is marked as already being in deployment. + when: '"active-deployment" in tags' + + - name: Check platform + fail: + msg: The object does not contain a valid platform attribute. + when: os != 'openSUSE-Leap-x86_64' + + - name: Write tag and journal + import_tasks: "../tasks/netbox_tags_pre.yml" + + - name: Gather site configuration + block: + - import_tasks: "../tasks/netbox_query_site.yml" + - import_tasks: "../tasks/netbox_evaluate_site.yml" + no_log: true + + - name: Gather prefix + block: + - import_tasks: "../tasks/netbox_query_prefix.yml" + - import_tasks: "../tasks/netbox_evaluate_prefix.yml" + no_log: true + + - name: Gather IP address + block: + - import_tasks: "../tasks/netbox_query_ip.yml" + - import_tasks: "../tasks/netbox_evaluate_ip.yml" + no_log: true + + - name: Provision virtual machine + import_tasks: "../tasks/configure_libvirt.yml" + + - name: Configure DHCP + import_tasks: "../tasks/init_dhcp.yml" + + +# - name: Prepare unattended installation (TO-DO if needed - not needed if script inside autoinst.xml fetches values itself) +# block: +# - import_tasks: "../tasks/prepare_platform_{{ os }}.yml" + + + always: + - name: Restore original tags + import_tasks: "../tasks/netbox_tags_post.yml" + + - name: Remove lock + file: + path: "{{ lockfile }}" + state: absent + delegate_to: localhost + + - name: Debug + ansible.builtin.debug: + msg: "{{ status if status is defined}} - {{ tags if tags is defined }} - {{ host if host is defined }} - {{ host_status if host_status is defined }} - {{ os if os is defined }} - {{ vcpus if vcpus is defined }} - {{ memory if memory is defined }} - {{ disk if disk is defined }}" + diff --git a/ansible/deployment_poc/tasks/configure_dhcp.yml b/ansible/deployment_poc/tasks/configure_dhcp.yml new file mode 100644 index 0000000..9802b0e --- /dev/null +++ b/ansible/deployment_poc/tasks/configure_dhcp.yml @@ -0,0 +1,31 @@ +--- +- name: Configure DHCP + block: + - name: Query DHCP server + set_fact: + dhcp_os: "{{ hostvars[dhcp_host]['platforms'][0] }}" + + - name: Insert DHCP host block + ansible.builtin.blockinfile: + #backup: yes + block: "{{ lookup('template', '../templates/dhcpd.conf.j2') }}" + marker: "### {mark} Ansible managed block for {{ vm_name }} ###" + path: "/etc/dhcpd.conf" + #delegate_to: "{{ dhcp_host }}" + become: yes + become_method: doas + when: dhcp_os == 'openbsd-x86_64' + + - name: Insert DHCP static mapping + vyos.vyos.vyos_config: + backup: yes + backup_options: + dir_path: "/tmp/" + comment: "Configured as part of {{ vm_name }} deployment" + lines: + - "set service dhcp-server shared-network-name LAN subnet {{ prefix_display }} static-mapping {{ vm_name }} mac-address {{ mac_address }}" + - "set service dhcp-server shared-network-name LAN subnet {{ prefix_display }} static-mapping {{ vm_name }} ip-address {{ ip_address }}" + save: no # CHANGE BEFORE ROLLOUT + when: dhcp_os == 'vyos-x86_64' + delegate_to: "{{ dhcp_host }}" + diff --git a/ansible/deployment_poc/tasks/configure_libvirt.yml b/ansible/deployment_poc/tasks/configure_libvirt.yml new file mode 100644 index 0000000..b3e49b6 --- /dev/null +++ b/ansible/deployment_poc/tasks/configure_libvirt.yml @@ -0,0 +1,61 @@ +--- +- name: Provision VM + block: + - name: Create domain template + ansible.builtin.template: + src: "../templates/libvirt-template.xml.j2" + dest: "../templates/libvirt-{{ inventory_hostname }}.xml" + group: lysergic + mode: '0660' + + - name: Create storage template + ansible.builtin.template: + src: "../templates/libvirt-storage-template.xml.j2" + dest: "../templates/generated/libvirt-storage-{{ inventory_hostname }}.xml" + group: lysergic + mode: '0660' + + - name: Define domain + virt: + uri: "{{ libvirt_url }}" + command: define + xml: "{{ lookup('template', '../templates/libvirt-template.xml.j2') }}" + autostart: no + # delegate_to: localhost + + - name: Query volumes + ansible.builtin.command: + argv: + - /usr/bin/virsh + - -c + - "{{ libvirt_url }}" + - vol-list + - "{{ storage.name }}" + register: volumes + no_log: true + + - name: Define volume + ansible.builtin.command: + argv: + - /usr/bin/virsh + - -c + - "{{ libvirt_url }}" + - vol-create + - "{{ storage.name }}" + - "../templates/generated/libvirt-storage-{{ inventory_hostname }}.xml" + when: vm_name not in volumes.stdout + + - name: Fetch MAC address + ansible.builtin.shell: "/usr/bin/virsh -c {{ libvirt_url }} domiflist {{ vm_name }} | awk '{print $5}' | cut -d/ -f 1 | tail -n 2 | head -n1" # ewww :-( + register: domiflist_mac + + - name: Store MAC address + set_fact: + mac_address: "{{ domiflist_mac.stdout }}" + + delegate_to: localhost + + always: + - name: Debug + ansible.builtin.debug: + msg: "{{ libvirt_url if libvirt_url is defined }} - {{ storage.name if storage is defined }} - {{ mac_address if mac_address is defined }}" diff --git a/ansible/deployment_poc/tasks/init_dhcp.yml b/ansible/deployment_poc/tasks/init_dhcp.yml new file mode 100644 index 0000000..fbd4765 --- /dev/null +++ b/ansible/deployment_poc/tasks/init_dhcp.yml @@ -0,0 +1,7 @@ +--- +- name: Initialize DHCP configurator + include_tasks: "../tasks/configure_dhcp.yml" + vars: + dhcp_host: "{{ item }}" + with_items: "{{ dhcp_servers }}" + diff --git a/ansible/deployment_poc/tasks/netbox_evaluate_cluster.yml b/ansible/deployment_poc/tasks/netbox_evaluate_cluster.yml new file mode 100644 index 0000000..1e8b07f --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_evaluate_cluster.yml @@ -0,0 +1,50 @@ +--- +- name: Evaluate cluster + block: + - name: Increment counters + set_fact: + retry_count: "{{ 0 if retry_count is undefined else retry_count | int +1 }}" + host_count: "{{ 0 if retry_count is undefined else host_count | int +1 }}" + + - name: Pick cluster host + set_fact: + #host_choice: "{{ nb_hosts.json.results[nb_hosts.json.count | random | int] }}" #PICK RANDOM + #host_choice: "{{ nb_hosts.json.results[1] }}" #FAIL TEST + host_choice: "{{ nb_hosts.json.results[host_count | int] }}" #INCREMENT + no_log: true + + - name: Evaluate cluster host status + set_fact: + host_status: "{{ host_choice.status.value }}" + #register: host_status + + - name: Evaluate cluster host name + set_fact: + host: "{{ host_choice.name }}" + + - name: Evaluate cluster host status + fail: + msg: Host is not ready. + when: host_status != 'active' + + - name: Evaluate cluster host configuration + set_fact: + storage: "{{ host_choice.config_context.storage[0] }}" + #deployment_servers: "{{ host_choice.config_context.deployment_servers }}" + dhcp_servers: "{{ host_choice.config_context.dhcp_servers }}" + dns_servers: "{{ host_choice.config_context.dns_servers }}" + when: host_status == 'active' + + rescue: + - name: Check retry counter + fail: + msg: "Too many retries - no host is ready" + when: retry_count | int == 3 and host_status != 'active' + + - debug: + msg: "{{ host if host is defined }} - {{ host_status if host_status is defined }}" + + - name: Re-evaluate cluster + include_tasks: "../tasks/netbox_evaluate_cluster.yml" + when: host_status != 'active' + diff --git a/ansible/deployment_poc/tasks/netbox_evaluate_ip.yml b/ansible/deployment_poc/tasks/netbox_evaluate_ip.yml new file mode 100644 index 0000000..828b15e --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_evaluate_ip.yml @@ -0,0 +1,5 @@ +--- +- name: Define IP address + set_fact: + ip_address: "{{ nb_ip.json[0].address | ansible.netcommon.ipaddr('address') }}" + diff --git a/ansible/deployment_poc/tasks/netbox_evaluate_prefix.yml b/ansible/deployment_poc/tasks/netbox_evaluate_prefix.yml new file mode 100644 index 0000000..74983e4 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_evaluate_prefix.yml @@ -0,0 +1,6 @@ +--- +- name: Evaluate prefix options + set_fact: + prefix_id: "{{ nb_prefix.json.results[0].id }}" + prefix_display: "{{ nb_prefix.json.results[0].display }}" + diff --git a/ansible/deployment_poc/tasks/netbox_evaluate_site.yml b/ansible/deployment_poc/tasks/netbox_evaluate_site.yml new file mode 100644 index 0000000..abd5347 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_evaluate_site.yml @@ -0,0 +1,5 @@ +--- +- name: Gather site configuration + set_fact: + site_id: "{{ nb_site.json.results[0].id }}" + diff --git a/ansible/deployment_poc/tasks/netbox_evaluate_vm.yml b/ansible/deployment_poc/tasks/netbox_evaluate_vm.yml new file mode 100644 index 0000000..8188024 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_evaluate_vm.yml @@ -0,0 +1,23 @@ +--- +- name: Pick hard- and software + # not needed, can be pulled from hostvars + set_fact: + vcpus: "{{ nb_vm.json.results[0].vcpus | int }}" + os: "{{ nb_vm.json.results[0].platform.name }}" + +# - name: Pick virtual hardware specifications +# # not needed, part of hostvars +# set_fact: +# memory: "{{ nb_vm.json.results[0].memory }}" +# disk: "{{ nb_vm.json.results[0].disk }}" + +- name: Pick metadata + set_fact: + id: "{{ nb_vm.json.results[0].id }}" + site: "{{ hostvars[inventory_hostname]['sites'][0] }}" + status: "{{ nb_vm.json.results[0].status.value }}" + +# # not needed, part of hostvars +# #tags: "{{ nb_vm.json.results[0].tags[0].slug }}" +# #tags: "{{ nb_vm.json.results[0].tags | sum(start=[]) | map(attribute='slug') }}" + diff --git a/ansible/deployment_poc/tasks/netbox_query_cluster.yml b/ansible/deployment_poc/tasks/netbox_query_cluster.yml new file mode 100644 index 0000000..1f948d1 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_query_cluster.yml @@ -0,0 +1,14 @@ +--- +- name: Locate cluster hosts + ansible.builtin.uri: + url: "{{ endpoint }}/dcim/devices/?cluster_id={{ nb_vm.json.results[0].cluster.id }}" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: GET + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + register: nb_hosts + delegate_to: localhost + diff --git a/ansible/deployment_poc/tasks/netbox_query_ip.yml b/ansible/deployment_poc/tasks/netbox_query_ip.yml new file mode 100644 index 0000000..f0ed7b7 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_query_ip.yml @@ -0,0 +1,14 @@ +--- +- name: Query available address + ansible.builtin.uri: + url: "{{ endpoint }}/ipam/prefixes/{{ prefix_id }}/available-ips/?limit=1" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: GET + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + register: nb_ip + delegate_to: localhost + diff --git a/ansible/deployment_poc/tasks/netbox_query_prefix.yml b/ansible/deployment_poc/tasks/netbox_query_prefix.yml new file mode 100644 index 0000000..d0c0990 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_query_prefix.yml @@ -0,0 +1,14 @@ +--- +- name: Query prefix + ansible.builtin.uri: + url: "{{ endpoint }}/ipam/prefixes/?site_id={{ site_id }}&tenant={{ tenant }}&limit=1" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: GET + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + register: nb_prefix + delegate_to: localhost + diff --git a/ansible/deployment_poc/tasks/netbox_query_site.yml b/ansible/deployment_poc/tasks/netbox_query_site.yml new file mode 100644 index 0000000..5894a6c --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_query_site.yml @@ -0,0 +1,14 @@ +--- +- name: Query site + ansible.builtin.uri: + url: "{{ endpoint }}/dcim/sites/?slug={{ site }}" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: GET + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + register: nb_site + delegate_to: localhost + diff --git a/ansible/deployment_poc/tasks/netbox_query_vm.yml b/ansible/deployment_poc/tasks/netbox_query_vm.yml new file mode 100644 index 0000000..52308f0 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_query_vm.yml @@ -0,0 +1,15 @@ +--- + # consider ditching this block, would need to work around missing cluster ID in hostvars +- name: Query VM + ansible.builtin.uri: + url: "{{ endpoint }}/virtualization/virtual-machines/?name={{ inventory_hostname }}" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: GET + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + register: nb_vm + delegate_to: localhost + diff --git a/ansible/deployment_poc/tasks/netbox_tags_post.yml b/ansible/deployment_poc/tasks/netbox_tags_post.yml new file mode 100644 index 0000000..9b24ca3 --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_tags_post.yml @@ -0,0 +1,24 @@ +--- +- name: Post-deployment tagging + block: + - name: Construct body for tagging + set_fact: + body2: ' {% for tag in tag_exist %}{% if loop.last %}{"slug": "{{ tag }}"}{% else %}{"slug": "{{ tag }}"},{% endif %}{% endfor %}' + when: tag_exist is defined + + - name: Set post-deployment tags + ansible.builtin.uri: + url: "{{ endpoint }}/virtualization/virtual-machines/{{ id }}/" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: PATCH + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + body_format: json + body: ' {"tags": [ {{ body2 }}]}' + delegate_to: localhost + when: body2 is defined + no_log: true + diff --git a/ansible/deployment_poc/tasks/netbox_tags_pre.yml b/ansible/deployment_poc/tasks/netbox_tags_pre.yml new file mode 100644 index 0000000..23a804b --- /dev/null +++ b/ansible/deployment_poc/tasks/netbox_tags_pre.yml @@ -0,0 +1,34 @@ +--- +- name: Pre-deployment tagging + block: + - name: Gather tags + set_fact: + tag_exist: "{{ tags }}" + tag_append: "['active-deployment']" + + - name: Merge tags + set_fact: + tag_merged: "{{ tag_merged + [item] }}" + with_items: + - "{{ tag_exist }}" + - "{{ tag_append }}" + + - name: Construct body for tagging + set_fact: + body1: ' {% for tag in tag_merged %}{% if loop.last %}{"slug": "{{ tag }}"}{% else %}{"slug": "{{ tag }}"},{% endif %}{% endfor %}' + + - name: Set pre-deployment tags + ansible.builtin.uri: + url: "{{ endpoint }}/virtualization/virtual-machines/{{ id }}/" + client_cert: "{{ cert }}" + client_key: "{{ key }}" + method: PATCH + return_content: yes + headers: + Accept: application/json + Authorization: "Token {{ token }}" + body_format: json + body: ' {"tags": [ {{ body1 }}]}' + delegate_to: localhost + no_log: true + diff --git a/ansible/deployment_poc/templates/dhcpd.conf.j2 b/ansible/deployment_poc/templates/dhcpd.conf.j2 new file mode 100644 index 0000000..5309ae4 --- /dev/null +++ b/ansible/deployment_poc/templates/dhcpd.conf.j2 @@ -0,0 +1,5 @@ +host {{ vm_name }} { + hardware ethernet {{ mac_address }}; + fixed-address {{ ip_address }}; + filename "replace-with-bootfile"; +} diff --git a/ansible/deployment_poc/templates/libvirt-storage-template.xml.j2 b/ansible/deployment_poc/templates/libvirt-storage-template.xml.j2 new file mode 100644 index 0000000..9ce3ff1 --- /dev/null +++ b/ansible/deployment_poc/templates/libvirt-storage-template.xml.j2 @@ -0,0 +1,16 @@ + + {{ inventory_hostname }}_root_disk.qcow2 + + + {{ disk }} + + {{ storage.name }} + + + 0660 + 107 + 107 + + + + diff --git a/ansible/deployment_poc/templates/libvirt-template.xml.j2 b/ansible/deployment_poc/templates/libvirt-template.xml.j2 new file mode 100644 index 0000000..8c4170d --- /dev/null +++ b/ansible/deployment_poc/templates/libvirt-template.xml.j2 @@ -0,0 +1,174 @@ + + {{ inventory_hostname }} + + + + + {{ memory }} + {{ memory }} + {{ vcpus }} + + /machine + + + hvm + /usr/share/qemu/ovmf-x86_64-code.bin + /var/lib/libvirt/qemu/nvram/{{ inventory_hostname }}_VARS.fd + + + + + + + + + Broadwell-IBRS + Intel + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + destroy + + + + + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + +
+ + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + /dev/urandom + +
+ + + + diff --git a/ansible/deployment_poc/variables/deploy-variables.yml b/ansible/deployment_poc/variables/deploy-variables.yml new file mode 100644 index 0000000..fbb4cc1 --- /dev/null +++ b/ansible/deployment_poc/variables/deploy-variables.yml @@ -0,0 +1,8 @@ +--- +lockfile: "../locks/deploy.lock" +endpoint: "" +cert: "" +key: "" +nb_token: +libvirt_url: "qemu+tls://{{ host }}/system" +tenant: "" -- cgit v1.2.3