Skip to content

Commit

Permalink
Enable no-free-form rule and refactor tasks (vitabaks#377)
Browse files Browse the repository at this point in the history
* 🔥 chore(ansible-lint.yml): remove no-free-form rule from skip_list
The no-free-form rule was removed from the skip_list in order to enable it. This rule checks that all tasks have a `task` key and that it is not a free-form task.

* 🎨 style(ansible): reformat service task in ansible-role-firewall and set_fact tasks in consul role
The service task in ansible-role-firewall was reformatted to use a dictionary for the service name and state. This improves readability and consistency with other tasks in the playbook. The set_fact tasks in the consul role were also reformatted to use a dictionary for the variable assignment. This improves readability and consistency with other tasks in the playbook.
  • Loading branch information
ThomasSanson authored Jun 10, 2023
1 parent dbfa7f9 commit 9436b23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion .config/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ skip_list:
- name[missing] # All tasks should be named.
- name[template] # Rule for checking task and play names
- no-changed-when
- no-free-form
- no-handler
- no-relative-paths
- package-latest
Expand Down
4 changes: 3 additions & 1 deletion roles/ansible-role-firewall/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
- name: restart firewall
service: name=firewall state=restarted
service:
name: firewall
state: restarted
9 changes: 6 additions & 3 deletions roles/consul/tasks/encrypt_gossip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
run_once: true

- name: Save gossip encryption key from existing configuration
set_fact: consul_raw_key={{ consul_key_read.stdout }}
set_fact:
consul_raw_key: "{{ consul_key_read.stdout }}"
ignore_errors: true

when:
Expand All @@ -31,7 +32,8 @@
delegate_to: 127.0.0.1

- name: Read gossip encryption key for servers that require it
set_fact: consul_raw_key="{{ lookup('file', '/tmp/consul_raw.key') }}"
set_fact:
consul_raw_key: "{{ lookup('file', '/tmp/consul_raw.key') }}"
when:
- consul_raw_key is not defined
- bootstrap_state.stat.exists | bool
Expand All @@ -55,7 +57,8 @@
run_once: true

- name: Write gossip encryption key to fact
set_fact: consul_raw_key={{ consul_keygen.stdout }}
set_fact:
consul_raw_key: "{{ consul_keygen.stdout }}"
when:
- consul_raw_key is not defined
- not bootstrap_state.stat.exists | bool

0 comments on commit 9436b23

Please sign in to comment.