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

FQCN #10

Merged
merged 1 commit into from
Oct 24, 2023
Merged

FQCN #10

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
1 change: 0 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
skip_list:
- experimental # all rules tagged as experimental
- fqcn-builtins
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: Start cron
service:
ansible.builtin.service:
name: crond
state: started
...
12 changes: 6 additions & 6 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
goss_format: tap
tasks:
- name: Download and install Goss
get_url:
ansible.builtin.get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
checksum: "sha256:{{ goss_sha256sum }}"
Expand All @@ -28,26 +28,26 @@
retries: 3

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
ansible.builtin.shell: "ls {{ goss_test_directory }}/test_*.yml"
changed_when: false
register: test_files

- name: Execute Goss tests
environment:
# yamllint disable-line rule:line-length
# yamllint disable rule:line-length
PATH: '/opt/rh/rh-git218/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
command: "{{ goss_dst }} -g {{ item }} validate -f {{ goss_format }}"
ansible.builtin.command: "{{ goss_dst }} -g {{ item }} validate -f {{ goss_format }}"
changed_when: false
register: test_results
with_items: "{{ test_files.stdout_lines }}"

- name: Display details about the Goss results
debug:
ansible.builtin.debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"

- name: Fail when tests fail
fail:
ansible.builtin.fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
Expand Down
26 changes: 13 additions & 13 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

- name: Include OS-specific variables.
# yamllint disable-line rule:line-length
include_vars: "{{ ansible_os_family }}{{ ansible_distribution_major_version }}.yml"
ansible.builtin.include_vars: "{{ ansible_os_family }}{{ ansible_distribution_major_version }}.yml"

- name: Ensure goss directory exists
file:
ansible.builtin.file:
path: /etc/goss.d/
state: directory
owner: root
Expand All @@ -15,27 +15,27 @@
- base_crontab

- name: Copy goss tests template
template:
ansible.builtin.template:
src: test_cron.yml.j2
dest: /etc/goss.d/test_cron.yml
mode: 0640
tags:
- base_crontab

- name: Ensure cron package is installed
package:
ansible.builtin.package:
name: "{{ crontab_packages }}"
state: present
notify: Start cron

- name: Ensure cron daemon is enabled
service:
ansible.builtin.service:
name: "{{ crond_service }}"
enabled: true
state: started

- name: Ensure permissions on /etc/crontab are configured
file:
ansible.builtin.file:
dest: /etc/crontab
owner: root
group: root
Expand All @@ -44,7 +44,7 @@
- permissions

- name: Ensure permissions on cron directories are configured
file:
ansible.builtin.file:
dest: "{{ item }}"
state: directory
owner: root
Expand All @@ -61,14 +61,14 @@
- permissions

- name: Remove /etc/at.deny
file:
ansible.builtin.file:
path: /etc/at.deny
state: absent
tags:
- crontab

- name: Copy /etc/at.allow file
template:
ansible.builtin.template:
src: at.allow.j2
dest: /etc/at.allow
owner: root
Expand All @@ -78,14 +78,14 @@
- crontab

- name: Remove /etc/cron.deny
file:
ansible.builtin.file:
path: /etc/cron.deny
state: absent
tags:
- crontab

- name: Copy /etc/cron.allow file
template:
ansible.builtin.template:
src: cron.allow.j2
dest: /etc/cron.allow
owner: root
Expand All @@ -95,7 +95,7 @@
- crontab

- name: Unconfigure jobs
cron:
ansible.builtin.cron:
name: "{{ item.name }}"
user: "{{ item.user | default('root') }}"
state: absent
Expand All @@ -106,7 +106,7 @@
- crontab

- name: Configure jobs
cron:
ansible.builtin.cron:
minute: "{{ item.value.minute | default('*') }}"
hour: "{{ item.value.hour | default('*') }}"
weekday: "{{ item.value.weekday | default('*') }}"
Expand Down