style(dhcpd): name of tasks, use built in module
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Markus Pesch 2023-02-12 14:39:48 +01:00
parent d3697463ee
commit f791809f0f
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
--- ---
- name: restart dhcpd - name: Restart dhcpd
ansible.builtin.systemd: ansible.builtin.systemd:
name: "{{ dhcpd_service_name }}" name: "{{ dhcpd_service_name }}"
state: restarted state: restarted

View File

@ -1,22 +1,22 @@
--- ---
- name: check if at least one subnet is defined - name: Check if at least one subnet is defined
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- dhcpd_subnets | length > 0 - dhcpd_subnets | length > 0
fail_msg: "No subnet defined" fail_msg: "No subnet defined"
- name: Include OS-specific variables - name: Include OS-specific variables
include_vars: "{{ ansible_os_family }}.yml" ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
- name: install dhcpd with dependencies - name: Install dhcpd with dependencies
ansible.builtin.package: ansible.builtin.package:
name: "{{ item }}" name: "{{ item }}"
state: present state: present
with_items: with_items:
- "{{ dhcpd_package_names }}" - "{{ dhcpd_package_names }}"
- name: create dhcpd config - name: Create dhcpd config
ansible.builtin.template: ansible.builtin.template:
src: "dhcpd.conf.j2" src: "dhcpd.conf.j2"
dest: "{{ dhcpd_main_config }}" dest: "{{ dhcpd_main_config }}"
@ -24,25 +24,26 @@
group: "{{ dhcpd_unix_group }}" group: "{{ dhcpd_unix_group }}"
mode: 0644 mode: 0644
- name: cleanup cache files - name: Cleanup cache files
notify: Restart dhcpd
block: block:
- name: check if cache dir exists - name: Check if cache dir exists
stat: ansible.builtin.stat:
path: "{{ dhcpd_cache_directory }}" path: "{{ dhcpd_cache_directory }}"
register: cache_stats register: cache_stats
- name: remove cache dir - name: Remove cache dir
ansible.builtin.file: ansible.builtin.file:
path: "{{ dhcpd_cache_directory }}" path: "{{ dhcpd_cache_directory }}"
state: absent state: absent
when: cache_stats.stat.exists when: cache_stats.stat.exists
- name: create cache dir - name: Create cache dir
ansible.builtin.file: ansible.builtin.file:
path: "{{ dhcpd_cache_directory }}" path: "{{ dhcpd_cache_directory }}"
owner: "{{ dhcpd_unix_user }}" owner: "{{ dhcpd_unix_user }}"
group: "{{ dhcpd_unix_group }}" group: "{{ dhcpd_unix_group }}"
mode: 0755 mode: 0755
state: directory state: directory
- name: create cache files - name: Create cache files
ansible.builtin.file: ansible.builtin.file:
path: "{{ dhcpd_cache_directory }}/{{ item }}" path: "{{ dhcpd_cache_directory }}/{{ item }}"
owner: "{{ dhcpd_unix_user }}" owner: "{{ dhcpd_unix_user }}"
@ -51,9 +52,8 @@
state: touch state: touch
with_items: with_items:
- dhcpd.leases - dhcpd.leases
notify: restart dhcpd
- name: start and enable dhcpd - name: Start and enable dhcpd
ansible.builtin.systemd: ansible.builtin.systemd:
name: "{{ item }}" name: "{{ item }}"
state: started state: started