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

Add support for builtin -hosts and -null maps #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
- item.mountpoint is defined
- item.mountpoint is string
- item.mountpoint is not none
quiet: yes
loop: "{{ autofs_maps }}"
loop_control:
label: "{{ item.mountpoint }}"
when:
- autofs_maps is defined
- item.state is undefined or (item.state is defined and item.state == "present")

- name: assert | Test directories defined when not using builtin map
ansible.builtin.assert:
that:
- item.directories is defined
- item.directories is iterable
quiet: yes
Expand All @@ -32,6 +43,7 @@
when:
- autofs_maps is defined
- item.state is undefined or (item.state is defined and item.state == "present")
- item.options is defined and ("-hosts" not in item.options and "-null" not in item.options)

- name: assert | Test item name in autofs_maps
ansible.builtin.assert:
Expand Down
3 changes: 2 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
notify:
- Reload autofs
when:
- item.state is not defined or (item.state is defined and item.state == "present")
- (item.state is not defined or (item.state is defined and item.state == "present"))
- item.options is defined and ("-hosts" not in item.options and "-null" not in item.options)

- name: Cleanup autofs file that should not exist
ansible.builtin.file:
Expand Down
2 changes: 1 addition & 1 deletion templates/template.autofs.j2
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{ ansible_managed | comment }}
{{ item.mountpoint }} /etc/auto.{{ item.name | default(item.mountpoint) | regex_replace('^/', '') | regex_replace('/', autofs_slash_replace_char) }} {% if item.options is defined %}{% for option in item.options %}{{ option }}{% if not loop.last %} {% endif %}{% endfor %} {% endif %}
{{ item.mountpoint }}{% if item.options is defined and ("-hosts" not in item.options and "-null" not in item.options) %} /etc/auto.{{ item.name | default(item.mountpoint) | regex_replace('^/', '') | regex_replace('/', autofs_slash_replace_char) }}{% endif %} {% if item.options is defined %}{% for option in item.options %}{{ option }}{% if not loop.last %} {% endif %}{% endfor %} {% endif %}