matrixtest-IaC-ansible/kubenodes.yaml

51 lines
1.6 KiB
YAML
Raw Normal View History

2024-01-15 09:21:45 +00:00
---
- name: Create os volume for kubernetes nodes
2024-01-15 09:21:45 +00:00
openstack.cloud.volume:
state: present
size: 30
image: debian-12
is_bootable: true
name: kube{{ item }}-matrix-test-sunet-se-osvol
2024-01-15 21:42:19 +00:00
loop: "{{ range(1, numnodes + 1 )|list }}"
- name: Create snap volume for kubernetes nodes
openstack.cloud.volume:
state: present
size: 20
is_bootable: false
name: kube{{ item }}-matrix-test-sunet-se-snapvol
2024-01-15 21:42:19 +00:00
loop: "{{ range(1, numnodes + 1 )|list }}"
2024-01-15 14:17:06 +00:00
- name: OS secgroups
openstack.cloud.security_group_info:
register: secgroups
- openstack.cloud.port:
state: present
name: kube{{ item }}-matrix-test-sunet-se-port
network: public
2024-01-15 14:45:19 +00:00
security_groups: |-
2024-01-16 06:40:38 +00:00
{%- set secgrlist = [] -%}
{%- for sg in kubesecgroups -%}
{% set sgdict=secgroups.security_groups|selectattr('name', 'equalto', sg )| first -%}
{{- secgrlist.append(sgdict['id']) -}}
{%- endfor -%}
{{ secgrlist | join(',') }}
2024-01-15 21:42:19 +00:00
loop: "{{ range(1, numnodes + 1 )|list }}"
2024-01-15 15:22:37 +00:00
- name: Launch kubernetes instances
openstack.cloud.server:
name: "kube{{ item }}.matrix-test.sunet.se"
state: present
flavor: b2.c4r16
2024-01-15 15:58:00 +00:00
key_name: manderssonpub
boot_volume: kube{{ item }}-matrix-test-sunet-se-osvol
volumes:
- "kube{{ item }}-matrix-test-sunet-se-snapvol"
2024-01-15 15:52:42 +00:00
nics:
- port-name: "kube{{ item }}-matrix-test-sunet-se-port"
2024-01-16 06:40:38 +00:00
security_groups: "{{ kubesecgroups | join(',') }}"
userdata: |
{{ lookup('ansible.builtin.template', 'kubenodes-user.yaml.j2') | indent(4, False ) }}
2024-01-15 21:42:19 +00:00
loop: "{{ range(1, numnodes + 1 )|list }}"