diff --git a/openstack/intel-worker/playbooks/roles/virtual_machine_create/defaults/main.yml b/openstack/intel-worker/playbooks/roles/virtual_machine_create/defaults/main.yml index 9ca084e..34be0e3 100644 --- a/openstack/intel-worker/playbooks/roles/virtual_machine_create/defaults/main.yml +++ b/openstack/intel-worker/playbooks/roles/virtual_machine_create/defaults/main.yml @@ -3,12 +3,14 @@ virtual_machine_create_name: rdr-mac-worker virtual_machine_create_region_name: RegionOne virtual_machine_create_availability_zone: Test -virtual_machine_create_image_name: 0c4d9ba3-ed14-403a-a35d-8b4c9f720f1f -virtual_machine_create_flavor: "PUN_custom_flavor" +virtual_machine_create_image_name: 4df699b6-6877-4b77-9ddb-0d6dc9cefb68 +virtual_machine_create_flavor: "m1.medium" virtual_machine_create_volume_size: 80 virtual_machine_create_keypair_name: pun_keypair virtual_machine_create_network_name: provider -virtual_machine_create_userdata: "#!/bin/sh\nyum -y install python3" +virtual_machine_create_userdata: "{{ lookup('template', 'worker-amd64.ign.j2') }}" +# virtual_machine_create_userdata: "{{ lookup('file', '/var/www/html/ignition/worker-amd64.ign') | string }}" +# virtual_machine_create_userdata: "#!/bin/sh\nyum -y install python3" # virtual_machine_userdata: "|\n#cloud-config\nchpasswd:\nlist: |\nubuntu:passw0rd\nexpire: False\npackages:\n- ansible\npackage_upgrade: true" # Examples: # userdata: | @@ -21,3 +23,18 @@ virtual_machine_create_userdata: "#!/bin/sh\nyum -y install python3" # - ansible # package_upgrade: true virtual_machine_create_timeout: 300 + +# Used in ignition task +virtual_machine_create_worker_hostname: "rdr-mac" +virtual_machine_create_worker_hostname_encoded: "" +virtual_machine_create_etc_resolve_encoded: "" +virtual_machine_create_dns_none_encoded: "" +virtual_machine_create_bastion_ip: "10.20.181.69" +virtual_machine_create_domain_name: "rdr-mac" +virtual_machine_create_http_port: "8080" +virtual_machine_create_https_port: "443" + +# Ignition Files +virtual_machine_create_dns_none_conf: |- + [main] + dns=none diff --git a/openstack/intel-worker/playbooks/roles/ignition.yml b/openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/ignition.yml similarity index 75% rename from openstack/intel-worker/playbooks/roles/ignition.yml rename to openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/ignition.yml index 6126faa..36cf38c 100644 --- a/openstack/intel-worker/playbooks/roles/ignition.yml +++ b/openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/ignition.yml @@ -1,7 +1,7 @@ --- - name: Create worker.ign and store it to /var/www/html/ignition/ ansible.builtin.get_url: - url: https://{{ bastion_ip }}:22623/config/worker + url: https://{{ virtual_machine_create_bastion_ip }}:22623/config/worker validate_certs: false dest: /var/www/html/ignition/worker-amd64.ign mode: "0644" @@ -14,8 +14,8 @@ - name: Set the variables (To be used in Customization Script) ansible.builtin.set_fact: - worker_hostname_encoded: "{{ worker_hostname | b64encode }}" - dns_none_encoded: "{{ dns_none_conf | b64encode }}" + worker_hostname_encoded: "{{ virtual_machine_create_worker_hostname | b64encode }}" + dns_none_encoded: "{{ virtual_machine_create_dns_none_conf | b64encode }}" etc_resolve_encoded: "{{ lookup('template', 'resolv.conf.j2') | b64encode }}" - name: Create the Intel ignition file diff --git a/openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/main.yml b/openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/main.yml index 21332d2..58895fc 100644 --- a/openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/main.yml +++ b/openstack/intel-worker/playbooks/roles/virtual_machine_create/tasks/main.yml @@ -1,5 +1,8 @@ --- # file: intel-worker-playbook.yml +- name: Add identity resources + ansible.builtin.include_tasks: + file: ignition.yml - name: Create server in the Multi-Arch Compute OpenStack Instance openstack.cloud.server: diff --git a/openstack/intel-worker/playbooks/roles/virtual_machine_create/templates/resolv.conf.j2 b/openstack/intel-worker/playbooks/roles/virtual_machine_create/templates/resolv.conf.j2 new file mode 100644 index 0000000..2980d19 --- /dev/null +++ b/openstack/intel-worker/playbooks/roles/virtual_machine_create/templates/resolv.conf.j2 @@ -0,0 +1,2 @@ +search {{ virtual_machine_create_domain_name }} +nameserver {{ virtual_machine_create_bastion_ip }} diff --git a/openstack/intel-worker/playbooks/roles/virtual_machine_create/templates/worker-amd64.ign.j2 b/openstack/intel-worker/playbooks/roles/virtual_machine_create/templates/worker-amd64.ign.j2 new file mode 100644 index 0000000..3a9ffd7 --- /dev/null +++ b/openstack/intel-worker/playbooks/roles/virtual_machine_create/templates/worker-amd64.ign.j2 @@ -0,0 +1,49 @@ +{ + "ignition": { + "version": "3.4.0", + "config": { + "merge": [ + { + "source": "http://{{ virtual_machine_create_bastion_ip }}:{{ virtual_machine_create_http_port }}/ignition/worker-amd64.ign" + } + ] + } + }, + "timeouts": { + "httpTotal": 15 + }, + "storage": { + "files": [ + { + "group": {}, + "path": "/etc/hostname", + "user": {}, + "contents": { + "source": "data:text/plain;base64,{{ virtual_machine_create_worker_hostname_encoded }}", + "verification": {} + }, + "mode": 420 + }, + { + "group": {}, + "path": "/etc/resolv.conf", + "user": {}, + "contents": { + "source": "data:text/plain;base64,{{ virtual_machine_create_etc_resolve_encoded }}", + "verification": {} + }, + "mode": 420 + }, + { + "group": {}, + "path": "/etc/NetworkManager/conf.d/90-dns-none.conf", + "user": {}, + "contents": { + "source": "data:text/plain;base64,{{ virtual_machine_create_dns_none_encoded }}", + "verification": {} + }, + "mode": 420 + } + ] + } +}