Skip to content

Commit

Permalink
style: Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Christie committed Sep 11, 2024
1 parent 2c11f69 commit cee2855
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@

skip_list:
- '204' # Lines should be no longer than 160 chars
- name[template]
- fqcn[action]
- fqcn[action-core]
- var-naming[no-role-prefix]
warn_list:
- '207' # Nested jinja pattern
5 changes: 3 additions & 2 deletions roles/player/tasks/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

- name: Collect names of all player Job Pods not complete
set_fact:
active_pods: "{{ pods_result|json_query('results[*].resources[*].metadata.name')|flatten }}"
active_pods: "{{ pods_result | json_query('results[*].resources[*].metadata.name') | flatten }}"

- name: Display collected Pod results
debug:
Expand All @@ -115,7 +115,8 @@
that: active_pods|length == 0
fail_msg: A play is still running. You must wait.

- include_tasks: wipe-pods.yaml
- name: Wipe Pods
include_tasks: wipe-pods.yaml

# Create basic materials

Expand Down
6 changes: 4 additions & 2 deletions roles/player/tasks/kill-player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#
# Use this if the play Pod itself s having trouble.

- include_tasks: prep.yaml
- name: Include prep.yaml
include_tasks: prep.yaml

- name: Check destructive change
pause:
Expand All @@ -22,4 +23,5 @@
wait: yes
wait_timeout: "{{ pod_ready_timeout }}"

- include_tasks: wipe-pods.yaml
- name: Wipe Pods
include_tasks: wipe-pods.yaml
12 changes: 7 additions & 5 deletions roles/player/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

- include_tasks: prep.yaml
- name: Include prep
include_tasks: prep.yaml

# A kubernetes host and an API key must be set.
# Either environment variables wil have been set by the user
Expand All @@ -18,11 +19,12 @@
# There is no 'undeploy' fragmentation is a 'Job'
# so there's (normally) nothing to delete.

- block:

- include_tasks: deploy.yaml

- name: Deploy
module_defaults:
group/k8s:
host: "{{ k8s_auth_host }}"
api_key: "{{ k8s_auth_api_key }}"
block:

- name: Include deploy
include_tasks: deploy.yaml
3 changes: 2 additions & 1 deletion roles/player/tasks/prep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Common playbook preparation.

# Expose ansible version
- debug:
- name: Display ansible version
debug:
var: ansible_version.full

# Expose all the installed Python modules...
Expand Down
24 changes: 12 additions & 12 deletions roles/player/tasks/query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

- name: Collect name of Running player Job Pods
set_fact:
running_pod: "{{ pod_result|json_query('resources[0].metadata.name') }}"
running_pod: "{{ pod_result | json_query('resources[0].metadata.name') }}"
when:
- query_message is undefined
- pod_result.resources|length > 0
Expand Down Expand Up @@ -56,7 +56,7 @@

- name: Collect name of Succeeded player Job Pods
set_fact:
finished_pod: "{{ pod_result|json_query('resources[0].metadata.name') }}"
finished_pod: "{{ pod_result | json_query('resources[0].metadata.name') }}"
when:
- query_message is undefined
- pod_result.resources|length > 0
Expand Down Expand Up @@ -84,7 +84,7 @@

- name: Collect name of Failed player Job Pods
set_fact:
failed_pod: "{{ pod_result|json_query('resources[0].metadata.name') }}"
failed_pod: "{{ pod_result | json_query('resources[0].metadata.name') }}"
when:
- query_message is undefined
- pod_result.resources|length > 0
Expand All @@ -111,7 +111,7 @@

- name: Collect name of Pending player Job Pods
set_fact:
pending_pod: "{{ pod_result|json_query('resources[0].metadata.name') }}"
pending_pod: "{{ pod_result | json_query('resources[0].metadata.name') }}"
when: pod_result.resources|length > 0

- name: Set Pending facts
Expand All @@ -135,7 +135,7 @@

- name: Collect name of Unknown player Job Pods
set_fact:
unkown_pod: "{{ pod_result|json_query('resources[0].metadata.name') }}"
unkown_pod: "{{ pod_result | json_query('resources[0].metadata.name') }}"
when:
- query_message is undefined
- pod_result.resources|length > 0
Expand All @@ -151,24 +151,24 @@
# Now print the summery message
# making sure we can deal with a failure to find anything.

- block:
- name: Display query message
when: query_message is defined
block:

- name: Get playbook name
set_fact:
query_play: "{{ query_pod_result|json_query(query)|flatten }}"
query_play: "{{ query_pod_result | json_query(query) | flatten }}"
vars:
query: "resources[0].spec.containers[0].env[?name=='FRAGMENTOR_PLAY'].value"

- name: Display query message
debug:
msg: The '{{ query_play[0] }}' play {{ query_message }}

when: query_message is defined

- block:
- name: Debug
when: query_message is undefined
block:

- name: Nothing found
debug:
msg: Nothing appears to be deployed

when: query_message is undefined
6 changes: 4 additions & 2 deletions site-player.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- hosts: localhost
- name: Localhost
hosts: localhost
tasks:
- include_role:
- name: Include player
include_role:
name: player
6 changes: 4 additions & 2 deletions site-player_kill-player.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- hosts: localhost
- name: Localhost
hosts: localhost
tasks:
- include_role:
- name: Include player kill-player
include_role:
name: player
tasks_from: kill-player.yaml
6 changes: 4 additions & 2 deletions site-player_query.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- hosts: localhost
- name: Localhost
hosts: localhost
tasks:
- include_role:
- name: Include player query
include_role:
name: player
tasks_from: query.yaml

0 comments on commit cee2855

Please sign in to comment.