Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions ansible/roles/values-prep/tasks/find-node-disks.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
---
- name: run lsblk on each nodes
vars:
- name: Run lsblk on each node
vars:
ip: "{{ lookup('vars', 'node_' ~ item ~ '_ip') }}"
shell: |
ssh core@{{ ip }} \
"lsblk -J -b -o NAME,TYPE,SIZE,MOUNTPOINT | jq -r '
.blockdevices[]
| select(.type == \"disk\")
| select(.size > 0)
| select((.children // []) | all(.mountpoint != \"/boot\"))
| \"/dev/\" + .name'"
ansible.builtin.shell:
cmd: >-
ssh core@{{ ip }}
"lsblk -J -b -o NAME,TYPE,SIZE,MOUNTPOINT | jq -r '
.blockdevices[] | select(.type == \"disk\") |
select(.size > 0 and .type == \"disk\") | select((.children // []) |
all(.mountpoint != \"/boot\")) | \"/dev/\" + .name'
register: blk_outputs
loop: "{{ range(0,3) | list }}"

- name: Extract device lists
set_fact:
ansible.builtin.set_fact:
node_disks_list: "{{ blk_outputs.results | map(attribute='stdout_lines') | list }}"

- name: Find common devices accross nodes
set_fact:
- name: Find common devices across nodes
ansible.builtin.set_fact:
common_disks: "{{ node_disks_list[0] | intersect(node_disks_list[1]) | intersect(node_disks_list[2]) }}"

- name: common disks
debug:
- name: Display common disks
ansible.builtin.debug:
msg: "{{ common_disks }}"
20 changes: 10 additions & 10 deletions ansible/roles/values-prep/tasks/get_iface.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
- name: Get interface for mac {{ item[0] }}
shell: >
ssh core@{{ node_0_ip }} "
ip -o link |
grep -i {{ item[0] }} |
awk -F': ' '{print \$2}' |
grep -v '[.@]'
"
- name: "Get interface for mac {{ item[0] }}"
ansible.builtin.shell:
cmd: >-
ssh core@{{ node_0_ip }} "
ip -o link |
awk -F': ' 'BEGIN{IGNORECASE=1} /{{ item[0] }}/ && \$2 !~ /^br/ {print \$2}' |
grep -v '[.@]'
"
register: iface
failed_when: iface.rc != 0 and iface.stdout == ""

- name: set iface to fact
set_fact:
- name: Set iface to fact for the current item
ansible.builtin.set_fact:
"{{ 'iface_' ~ item[1] }}": "{{ iface.stdout }}"
70 changes: 37 additions & 33 deletions ansible/roles/values-prep/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,85 @@
---
- name: get woker node names
shell: oc get nodes -o jsonpath='{.items[*].metadata.name}'
- name: Get worker node names
ansible.builtin.command:
cmd: oc get nodes -o jsonpath='{.items[*].metadata.name}'
register: node_names

- name: set node facts (node_*)
set_fact:
- name: Set node facts (node_*)
ansible.builtin.set_fact:
"{{ item_name }}": "{{ item }}"
loop: "{{ node_names.stdout.split() }}"
loop_control:
index_var: node_index
vars:
item_name: "node_{{ node_index }}"

- name: get the second node macs (2,3 and 4th macs)
set_fact:
- name: Get the second node MACs (2nd, 3rd and 4th MACs)
ansible.builtin.set_fact:
macs: "{{ ocp_inventory.json.nodes[1].mac[1:4] }}"

- name: get the ip of the first node
command: >
oc get nodes -o jsonpath="{range .items[*]}{.status.addresses[?(@.type=='InternalIP')].address}{'\n'}{end}"
register:
nodes_ip
- name: Get the IP of the first node
ansible.builtin.command:
cmd: oc get nodes -o jsonpath="{range .items[*]}{.status.addresses[?(@.type=='InternalIP')].address}{'\n'}{end}"
register: nodes_ip

- name: set node ip fact
set_fact:
- name: Set node IP fact
ansible.builtin.set_fact:
"{{ item_name }}": "{{ item }}"
loop: "{{ nodes_ip.stdout.split() }}"
loop_control:
index_var: node_index
vars:
item_name: "node_{{ node_index }}_ip"
item_name: "node_{{ node_index }}_ip"

- name: fix and setup ssh
include_tasks: setup-ssh.yml
- name: Fix and setup SSH
ansible.builtin.include_tasks:
file: setup-ssh.yml
loop: "{{ range(0, 3) | list }}"

- name: get the interface names
include_tasks: get_iface.yml
- name: Get the interface names
ansible.builtin.include_tasks:
file: get_iface.yml
loop: "{{ macs | zip(range(macs | length)) | map('list') | list }}"
loop_control:
loop_var: item

- name: set the ctlplane gateway ip
shell:
ip addr add 172.16.0.1/16 dev {{ iface_0 }}
become: yes
ignore_errors: yes
- name: Set the ctlplane gateway IP
ansible.builtin.command:
cmd: ip addr add 172.16.0.1/16 dev {{ iface_0 }}
become: true
ignore_errors: true

- name: set masquerade for the jump host
shell: |
iptables -t nat -A POSTROUTING -s 172.16.0.0/16 -o {{ iface_0 }} -j MASQUERADE
- name: Set masquerade for the jump host
ansible.builtin.command:
cmd: iptables -t nat -A POSTROUTING -s 172.16.0.0/16 -o {{ iface_0 }} -j MASQUERADE
become: true

- name: get the common disk accros nodes
include_tasks: find-node-disks.yml
- name: Get the common disk across nodes
ansible.builtin.include_tasks:
file: find-node-disks.yml

- name: Render nncp.yaml
template:
ansible.builtin.template:
src: nncp_values.yaml.j2
dest: "{{ dt_path }}/examples/dt/perfscale/scalelab/networking/nncp/values.yaml"

- name: Render service_values.yaml
template:
ansible.builtin.template:
src: service_values.yaml.j2
dest: "{{ dt_path }}/examples/dt/perfscale/scalelab/service-values.yaml"

- name: Render service_values_ceph.yaml
template:
ansible.builtin.template:
src: service_values_ceph.yaml.j2
dest: "{{ dt_path }}/examples/dt/perfscale/scalelab/service-values-ceph.yaml"
when: ceph_backend | default(false) | bool

- name: Render kustomization.yaml for controlplane
template:
ansible.builtin.template:
src: kustomization.yaml.j2
dest: "{{ dt_path }}/examples/dt/perfscale/scalelab/kustomization.yaml"

- name: Render lvms value
template:
ansible.builtin.template:
src: lvms-values.yaml.j2
dest: "{{ dt_path }}/examples/dt/perfscale/scalelab/lvms/lvm-cluster/values.yaml"
13 changes: 7 additions & 6 deletions ansible/roles/values-prep/tasks/setup-ssh.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- name: remove bad known_host entry if any
shell:
ssh-keygen -R {{ lookup('vars', 'node_' ~ item ~ '_ip') }}
ignore_errors: yes
- name: Remove bad known_host entry if any
ansible.builtin.command:
cmd: ssh-keygen -R {{ lookup('vars', 'node_' ~ item ~ '_ip') }}
ignore_errors: true

- name: Add node to known hosts
shell: ssh-keyscan -H {{ lookup('vars', 'node_' ~ item ~ '_ip') }} >> ~/.ssh/known_hosts
ignore_errors: yes
ansible.builtin.shell:
cmd: ssh-keyscan -H {{ lookup('vars', 'node_' ~ item ~ '_ip') }} >> ~/.ssh/known_hosts
ignore_errors: true