Skip to content

Commit

Permalink
Reconcile latest changes with SNO
Browse files Browse the repository at this point in the history
Use the common roles to execute regular
tasks, to avoid duplicates

Signed-off-by: Yolanda Robla <[email protected]>
  • Loading branch information
Yolanda Robla authored and yrobla committed Mar 18, 2021
1 parent df92f19 commit 5977599
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 78 deletions.
3 changes: 3 additions & 0 deletions ai-deploy-cluster-singlenode/inventory/hosts.sample
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ final_iso_path=/var/www/html
# final_iso_path=/home/share/
# need_racadm=false

# if virtualmedia is done over http
virtualmedia_over_http=True

### Network config (uncomment for static setting, or leave commented for DHCP)
# it needs to follow nmstate format
# network_config_path=./sample/worker_sno.yaml
Expand Down
56 changes: 14 additions & 42 deletions ai-deploy-cluster-singlenode/roles/create-cluster/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
---
- name: Create a temporary file
tempfile:
state: file
register: tempfile_pullsecret

- name: Copy pull secret to file
copy:
content: "{{ pull_secret }}"
dest: "{{ tempfile_pullsecret.path }}"

- name: Create cluster and download ISO
block:
- name: Create new AI cluster
shell: "aicli create cluster -P pull_secret={{ tempfile_pullsecret.path }} -P base_dns_domain={{ cluster_domain }} -P ssh_public_key='{{ ssh_public_key }}' -P high_availability_mode=None -P openshift_version='{{ cluster_version }}' {{ cluster_name }}"

- name: Retrieve cluster ID from name
shell: "aicli list cluster | grep {{ cluster_name }} | cut -d '|' -f3 | tr -d ' '"
register: cluster_id

- name: Set the right network type
uri:
url: "{{ ai_url }}/api/assisted-install/v1/clusters/{{ cluster_id.stdout }}/install-config"
method: PATCH
body: '"{\"networking\": {\"networkType\": \"{{ cluster_sdn | default("OVNKubernetes") }}\"}}"'
body_format: json
status_code: 201

- name: Copy the network file remotely if it exists
copy:
src: "{{ network_config_path }}"
dest: "{{ temporary_path }}/network_config"
when: network_config_path is defined and network_config_path|length>0

- name: Download the small ISO
shell: "aicli create iso --minimal -P ssh_public_key='{{ ssh_public_key}}' {% if network_config_path is defined and network_config_path|length > 0 %}--paramfile {{ temporary_path }}/network_config{% endif %} {{ cluster_name }}"

- name: And download it
shell: "aicli download iso {{ cluster_name }} -p {{ final_iso_path }}"

environment:
AI_URL: "{{ ai_url }}"

- name: create cluster
include_role:
name: "{{ playbook_dir }}/../common-roles/create-cluster"
vars:
extra_args: "-P high_availability_mode=None"
cluster_name_var: "{{ cluster_name }}"

- name: download ISO
include_role:
name: "{{ playbook_dir }}/../common-roles/download-iso"
vars:
cluster_name_var: "{{ cluster_name }}"
final_iso_path_var: "{{ final_iso_path }}"
minimal: True
23 changes: 13 additions & 10 deletions ai-deploy-cluster-singlenode/roles/deploy-cluster/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
---
- name: Configure cluster
- name: Configure host
block:
- block:
- name: Query for the host ID, there is only one as is SNO
shell: "aicli list hosts | grep {{ cluster_name }} | cut -d '|' -f 4"
register: host_id
when: hostname is defined

- name: Set the hostname for the given host_id
shell: "aicli update host {{ host_id.stdout | trim }} -P name={{ hostname }}"
when: host_id | length > 0
- name: Query for the host ID, there is only one as is SNO
shell: "aicli list hosts | grep {{ cluster_name }} | cut -d '|' -f 4"
register: host_id
when: hostname is defined

- name: Set the hostname for the given host_id
shell: "aicli update host {{ host_id.stdout | trim }} -P name={{ hostname }}"
when: host_id | length > 0
when: hostname is defined
environment:
AI_URL: "{{ ai_url }}"

- name: Configure cluster
block:
- name: Wait until cluster is ready to be installed
shell: "aicli list cluster | grep {{ cluster_name }} | cut -d '|' -f4 | tr -d ' '"
register: cluster_ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,12 @@
- podman
- openssl-devel
- make
- httpd
state: present

- name: make sure httpd landing page is disabled
copy:
content: "# Disabled"
dest: /etc/httpd/conf.d/welcome.conf
force: yes
group: root
owner: root
mode: 0644

- name: Enable and (re)start httpd
systemd:
name: httpd
enabled: yes
masked: no
state: restarted
- name: install httpd
include_role:
name: "{{ playbook_dir }}/../common-roles/install-httpd"
when: virtualmedia_over_http is defined and virtualmedia_over_http|bool == True

- name: Set openshift_versions json dict
ansible.builtin.set_fact:
Expand All @@ -31,18 +19,18 @@
"display_name": "{{ display_name }}",
"rhcos_image": "{{ rhcos_image }}",
"rhcos_version": "{{ rhcos_version }}",
"support_level": "{{ support_level }}"}}'
"support_level": "{{ support_level | default("beta") }}"
}
}'

- name: Set openshift_versions json object
ansible.builtin.set_fact:
openshift_versions: "{{ openshift_versions_dict | to_json }}"

- name: Set rhcos_base_iso to rhcos_image to avoid duplication
ansible.builtin.set_fact:
rhcos_base_iso: "{{ rhcos_image }}"

- name: install ISO generator scripts
include_role:
name: "{{ playbook_dir }}/../common-roles/install-iso-generator"

- name: install racadm
include_role:
name: "{{ playbook_dir }}/../common-roles/install-racadm"
Expand All @@ -64,5 +52,3 @@
- "OPENSHIFT_INSTALL_RELEASE_IMAGE={{ sno_image }}"
- "PUBLIC_CONTAINER_REGISTRIES=quay.io,registry.svc.ci.openshift.org"
- "RHCOS_BASE_ISO={{ rhcos_base_iso }}"


2 changes: 1 addition & 1 deletion common-roles/download-iso/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
when: network_config_path is defined and network_config_path|length>0

- name: Create the small ISO
shell: "aicli create iso {% if minimal is defined and minimal | bool == True%}--minimal{% endif %} -P ssh_public_key='{{ ssh_public_key}}' --paramfile {% if network_config_path is defined and network_config_path|length > 0 %}{{ temporary_path }}/network_config{% endif %} {{ cluster_name_var }}"
shell: "aicli create iso {% if minimal is defined and minimal | bool == True%}--minimal{% endif %} -P ssh_public_key='{{ ssh_public_key}}' {% if network_config_path is defined and network_config_path|length > 0 %}--paramfile {{ temporary_path }}/network_config{% endif %} {{ cluster_name_var }}"

- name: And download it
shell: "aicli download iso {{ cluster_name_var }} -p {{ final_iso_path_var }}"
Expand Down
4 changes: 2 additions & 2 deletions common-roles/install-assisted-installer/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: Clone the assisted installer project
git:
repo: 'https://github.com/openshift/assisted-service'
version: "{{ ai_version }}"
version: "{{ ai_version | default('HEAD') }}"
dest: /opt/assisted-service-ztp
update: yes
force: yes
Expand Down Expand Up @@ -35,7 +35,7 @@
chdir: "/opt/assisted-service-ztp"

- name: Start the assisted installer service
shell: "ASSISTED_TAG={{ assisted_tag }} make deploy-onprem"
shell: "ASSISTED_TAG={{ assisted_tag | default('latest') }} make deploy-onprem"
args:
chdir: "/opt/assisted-service-ztp"
environment:
Expand Down
22 changes: 22 additions & 0 deletions common-roles/install-httpd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: Install httpd package
yum:
name:
- httpd
state: present

- name: make sure httpd landing page is disabled
copy:
content: "# Disabled"
dest: /etc/httpd/conf.d/welcome.conf
force: yes
group: root
owner: root
mode: 0644

- name: Enable and (re)start httpd
systemd:
name: httpd
enabled: yes
masked: no
state: restarted

0 comments on commit 5977599

Please sign in to comment.