Skip to content

Commit

Permalink
OCTOPUS-718: Refactored code to small variable names
Browse files Browse the repository at this point in the history
Signed-off-by: Punith Kenchappa <[email protected]>
  • Loading branch information
pkenchap committed May 2, 2024
1 parent 39b1c2b commit 937abd3
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
tasks:
- name: Virtual machine create role in loop
ansible.builtin.include_role:
name: virtual_machine_create
name: vm_create
loop: "{{ range(0, iterations) | list }}"
loop_control:
loop_var: iteration
vars:
virtual_machine_create_name: "rdr-mac-worker-openstack-{{ iteration }}"
virtual_machine_create_worker_hostname: "rdr-mac-worker-openstack-{{ iteration }}"
vm_create_name: "rdr-mac-worker-openstack-{{ iteration }}"
vm_create_worker_hostname: "rdr-mac-worker-openstack-{{ iteration }}"

- name: Approve and issue
hosts: localhost
roles:
- approve_and_issue
- csr_approve
vars:
approve_and_issue_intel_count: 3
csr_approve_intel_count: 3

- name: Intel worker vitrual_machine create
hosts: localhost
roles:
- virtual_machine_action
- vm_action
vars:
virtual_machine_action_name: stop
vm_action_name: stop

- name: Intel worker vitrual_machine create
hosts: localhost
roles:
- virtual_machine_action
- vm_action
vars:
virtual_machine_action_name: start
vm_action_name: start
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
tasks:
- name: Virtual machine delete role in loop
ansible.builtin.include_role:
name: virtual_machine_delete
name: vm_delete
loop: "{{ range(0, iterations) | list }}"
loop_control:
loop_var: iteration
vars:
virtual_machine_delete_name: "rdr-mac-worker-openstack-{{ iteration }}"
vm_delete_name: "rdr-mac-worker-openstack-{{ iteration }}"

- name: Intel worker flavor create
hosts: localhost
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# Approve and issue vars
csr_approve_intel_count: 3
csr_approve_intel_prefix: "rdr-mac"
csr_approve_intel_zone: "openstack"
12 changes: 12 additions & 0 deletions openstack/intel-worker/playbooks/roles/csr_approve/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
# file to add the approve and issue csr certificate
- name: Copy the approve and issue file to tmp folder
ansible.builtin.copy:
src: "{{ role_path }}/files/csr_approve.sh"
dest: /tmp/csr_approve.sh
mode: "0755"

- name: Run the script to approve and issue csr certificate
ansible.builtin.script:
cmd: /tmp/csr_approve.sh "{{ csr_approve_intel_count }}" "{{ csr_approve_intel_prefix }}" "{{ csr_approve_intel_zone }}"
register: csr_approve_output

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# Virtual machine action
virtual_machine_action_name: stop
virtual_machine_action_vmname: rdr-mac-worker
vm_action_name: stop
vm_action_vmname: rdr-mac-worker
# server action list
# "lock"
# "pause"
Expand All @@ -17,5 +17,5 @@ virtual_machine_action_vmname: rdr-mac-worker
# "unlock"
# "unpause"
# "unshelve"
virtual_machine_action_timeout: 200
virtual_machine_action_wait: true
vm_action_timeout: 200
vm_action_wait: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Virtual machine action like start/stop/restart etc in the Multi-Arch Compute OpenStack

Check failure on line 2 in openstack/intel-worker/playbooks/roles/vm_action/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

syntax-check[unknown-module]

couldn't resolve module/action 'openstack.cloud.server_action'. This often indicates a misspelling, missing collection, or incorrect module path.
openstack.cloud.server_action:
cloud: openstack
action: "{{ vm_action_name }}"
server: "{{ vm_action_vmname }}"
timeout: "{{ vm_action_timeout }}"
wait: "{{ vm_action_wait }}"
28 changes: 28 additions & 0 deletions openstack/intel-worker/playbooks/roles/vm_create/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# Virtual_machine details
vm_create_name: rdr-mac-worker-openstack
vm_create_region_name: RegionOne
vm_create_availability_zone: Test
vm_create_image_name: 4df699b6-6877-4b77-9ddb-0d6dc9cefb68
vm_create_flavor: "m1.medium"
vm_create_volume_size: 80
vm_create_keypair_name: pun_keypair
vm_create_network_name: provider
vm_create_userdata: "{{ lookup('template', 'worker-amd64.ign.j2') }}"
vm_create_timeout: 300
vm_create_count: 3

# Used in ignition task
vm_create_worker_hostname: "rdr-mac-worker-openstack"
vm_create_worker_hostname_encoded: ""
vm_create_etc_resolve_encoded: ""
vm_create_dns_none_encoded: ""
vm_create_bastion_ip: "10.20.181.69"
vm_create_domain_name: "rdr-mac1"
vm_create_http_port: "8080"
vm_create_https_port: "443"

# Ignition Files
vm_create_dns_none_conf: |-
[main]
dns=none
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Get virtual machine info
openstack.cloud.server_info:
cloud: openstack
name: "{{ virtual_machine_create_name }}"
name: "{{ vm_create_name }}"
register: vm_info

- name: Print virtual machine vm_info
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Create worker.ign and store it to /var/www/html/ignition/
ansible.builtin.get_url:
url: https://{{ virtual_machine_create_bastion_ip }}:22623/config/worker
url: https://{{ vm_create_bastion_ip }}:22623/config/worker
validate_certs: false
dest: /var/www/html/ignition/worker-amd64.ign
mode: "0644"
Expand All @@ -17,9 +17,9 @@

- name: Set the variables (To be used in Customization Script)
ansible.builtin.set_fact:
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 }}"
vm_create_worker_hostname_encoded: "{{ vm_create_worker_hostname | b64encode }}"
vm_create_dns_none_encoded: "{{ vm_create_dns_none_conf | b64encode }}"
vm_create_etc_resolve_encoded: "{{ lookup('template', 'resolv.conf.j2') | b64encode }}"

- name: Create the Intel ignition file
ansible.builtin.template:
Expand Down
24 changes: 24 additions & 0 deletions openstack/intel-worker/playbooks/roles/vm_create/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
# file: intel-worker-playbook.yml
- name: Create ignition file
ansible.builtin.include_tasks:
file: ignition.yml

- name: Create server in the Multi-Arch Compute OpenStack Instance

Check failure on line 7 in openstack/intel-worker/playbooks/roles/vm_create/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

syntax-check[unknown-module]

couldn't resolve module/action 'openstack.cloud.server'. This often indicates a misspelling, missing collection, or incorrect module path.
openstack.cloud.server:
cloud: openstack
state: present
name: "{{ vm_create_name }}"
region_name: "{{ vm_create_region_name }}"
availability_zone: "{{ vm_create_availability_zone }}"
image: "{{ vm_create_image_name }}"
flavor: "{{ vm_create_flavor }}"
volume_size: "{{ vm_create_volume_size }}"
key_name: "{{ vm_create_keypair_name }}"
network: "{{ vm_create_network_name }}"
userdata: "{{ vm_create_userdata }}"
timeout: "{{ vm_create_timeout }}"

- name: Get and wait for VM in active state
ansible.builtin.include_tasks:
file: get_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
search {{ vm_create_domain_name }}
nameserver {{ vm_create_bastion_ip }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config": {
"merge": [
{
"source": "http://{{ virtual_machine_create_bastion_ip }}:{{ virtual_machine_create_http_port }}/ignition/worker-amd64.ign"
"source": "http://{{ vm_create_bastion_ip }}:{{ vm_create_http_port }}/ignition/worker-amd64.ign"
}
]
}
Expand All @@ -19,7 +19,7 @@
"path": "/etc/hostname",
"user": {},
"contents": {
"source": "data:text/plain;base64,{{ virtual_machine_create_worker_hostname_encoded }}",
"source": "data:text/plain;base64,{{ vm_create_worker_hostname_encoded }}",
"verification": {}
},
"mode": 420
Expand All @@ -29,7 +29,7 @@
"path": "/etc/resolv.conf",
"user": {},
"contents": {
"source": "data:text/plain;base64,{{ virtual_machine_create_etc_resolve_encoded }}",
"source": "data:text/plain;base64,{{ vm_create_etc_resolve_encoded }}",
"verification": {}
},
"mode": 420
Expand All @@ -39,7 +39,7 @@
"path": "/etc/NetworkManager/conf.d/90-dns-none.conf",
"user": {},
"contents": {
"source": "data:text/plain;base64,{{ virtual_machine_create_dns_none_encoded }}",
"source": "data:text/plain;base64,{{ vm_create_dns_none_encoded }}",
"verification": {}
},
"mode": 420
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# Virtual_machine details
vm_delete_name: rdr-mac-worker-openstack
vm_delete_count: 3
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
openstack.cloud.server:
cloud: openstack
state: absent
name: "{{ virtual_machine_delete_name }}"
name: "{{ vm_delete_name }}"
4 changes: 2 additions & 2 deletions openstack/intel-worker/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ virtual_machine_server_action: start
# "unlock"
# "unpause"
# "unshelve"
virtual_machine_action_timeout: 200
virtual_machine_action_wait: true
vm_action_timeout: 200
vm_action_wait: true

# Host aggregate details
host_aggregate_name: multi-arch-compute-aggregate
Expand Down

0 comments on commit 937abd3

Please sign in to comment.