Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add tags to tasks #11

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions playbooks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@
hosts: all:!bastion
roles:
- role: docker
tags:
- setup-all
- setup-docker
- role: consul
tags:
- setup-all
- setup-consul
- role: dns
tags:
- setup-all
- setup-dns

- name: setup nomad
import_playbook: sub_plays/nomad.yml
tags:
- setup-all
- setup-nomad

- name: setup system jobs on nomad
import_playbook: runtime.yml
tags:
- setup-all
- setup-runtime
6 changes: 2 additions & 4 deletions playbooks/roles/nomad/tasks/csi_plugins.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

- name: Deploy CSI Controller plugin
- name: Deploy CSI plugin
community.general.nomad_job:
host: "nomad.service.consul"
state: present
Expand All @@ -12,10 +12,8 @@

- name: Check the job state is healthy
ansible.builtin.uri:
url: "http://nomad.service.consul:4646/v1/job/{{ job_name }}"
url: "http://nomad.service.consul:4646/v1/job/plugin-{{ item }}"
method: GET
# headers:
# X-Nomad-Token: "{{ nomad_token }}"
remote_src: yes
register: job_status
until: job_status | json_query('json.Status') == 'running'
Expand Down
1 change: 1 addition & 0 deletions playbooks/roles/nomad/tasks/csi_volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
remote_src: yes
register: node_status
until: node_status | json_query('json.Status') == 'running'

- name: Create CSI volume with Nomad API
ansible.builtin.uri:
url: http://nomad.service.consul:4646/v1/volume/csi/{{ item.id }}/create
Expand Down
31 changes: 31 additions & 0 deletions playbooks/roles/nomad/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,34 @@
failed_when: false
loop: "{{ nomad_namespaces }}"
run_once: true

- block:
- name: Setup csi plugins
ansible.builtin.include_tasks:
file: "csi_plugins.yml"
apply:
tags:
- setup-all
- setup-csi
loop:
- azure_csi_controller
- azure_csi_node
tags:
- setup-all
- setup-csi
when: nomad_csi_volumes is defined
run_once: true

- name: Create csi volumes
ansible.builtin.include_tasks:
file: "csi_volumes.yml"
apply:
tags:
- setup-all
- setup-csi
loop: "{{ nomad_csi_volumes }}"
tags:
- setup-all
- setup-csi
when: nomad_csi_volumes is defined
run_once: true
2 changes: 1 addition & 1 deletion playbooks/roles/nomad/templates/azure_csi_node.hcl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ EOH
"local/azure.json:/etc/kubernetes/azure.json"
]
args = [
"--nodeid={{ nomad_csi_plugin_node_id }}",
"--nodeid=${attr.unique.hostname}",
"--endpoint=unix://csi/csi.sock",
"--logtostderr",
"--v=5",
Expand Down
4 changes: 2 additions & 2 deletions playbooks/roles/nomad/templates/csi-volumes.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"FsType": "{{ item.filesystem }}",
"MountFlags": ["noatime"]
},
"RequestedCapacityMin": {{ item.size }},
"RequestedCapacityMax": {{ item.size }},
"RequestedCapacityMin": {{ item.minsize }},
"RequestedCapacityMax": {{ item.maxsize }},
"RequestedCapabilities": [
{
"AccessMode": "single-node-writer",
Expand Down