diff options
author | Georg | 2022-01-05 23:59:13 +0100 |
---|---|---|
committer | Georg | 2022-01-05 23:59:13 +0100 |
commit | 7bb88aaa661dc6756e862562c47368de11657f44 (patch) | |
tree | 545d6f1d86c1d42ed04d558450996c54fdca631d /ansible/deployment_poc/playbooks | |
parent | 0e53f4d766e95205b20951fd252f6118ce05352b (diff) | |
download | system-7bb88aaa661dc6756e862562c47368de11657f44.tar.gz system-7bb88aaa661dc6756e862562c47368de11657f44.tar.bz2 system-7bb88aaa661dc6756e862562c47368de11657f44.zip |
Init Ansible NetBox DHCP POC deployment
Signed-off-by: Georg <georg@lysergic.dev>
Diffstat (limited to 'ansible/deployment_poc/playbooks')
-rw-r--r-- | ansible/deployment_poc/playbooks/deploy.yml | 104 |
1 files changed, 104 insertions, 0 deletions
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 }}" + |