diff --git a/group_vars/all/vars.yml b/group_vars/all/vars.yml index 03c6e23..3d18221 100644 --- a/group_vars/all/vars.yml +++ b/group_vars/all/vars.yml @@ -42,6 +42,8 @@ backend_imap_port: 12892 # Application configurations +global_ansible_facts_directory: "/etc/ansible/facts.d" + global_apt_sources_directory: "/etc/apt/sources.list.d" global_ssh_configuration_directory: "/etc/ssh/" diff --git a/roles/common/handlers/main.yml b/roles/common/handlers/main.yml index a69b509..81d8bc2 100644 --- a/roles/common/handlers/main.yml +++ b/roles/common/handlers/main.yml @@ -2,3 +2,6 @@ - name: generate locales command: locale-gen + +- name: reload facts + setup: diff --git a/roles/common/tasks/custom_facts.yml b/roles/common/tasks/custom_facts.yml new file mode 100644 index 0000000..6d57bd7 --- /dev/null +++ b/roles/common/tasks/custom_facts.yml @@ -0,0 +1,20 @@ +--- + +- name: Create custom facts directory + file: + state: directory + path: "{{ global_ansible_facts_directory }}" + owner: root + group: root + mode: "u=rwx,g=rx,o=rx" + +- name: Store custom apt fact + copy: + content: | + #!/bin/sh + echo "{\"architecture\": \"$(dpkg --print-architecture)\"}"; + dest: "{{ global_ansible_facts_directory }}/dpkg.fact" + owner: root + group: root + mode: "u=rwx,g=rx,o=rx" + notify: reload facts diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 21d69a0..5754124 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -12,6 +12,9 @@ - name: Configure locales include_tasks: locales.yml +- name: Configure custom facts + include_tasks: custom_facts.yml + - name: Configure helpers include_tasks: helpers.yml @@ -51,3 +54,6 @@ - "{{ backups_directory }}" - "{{ backups_databases_directory }}" - "{{ backups_files_directory }}" + +- name: Flush handlers for role + meta: flush_handlers