From e4f27abbfe44373934eb532fac98ff99fd89b198 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Wed, 11 Oct 2017 01:09:42 +0000 Subject: [PATCH] use integrated host_vars --- meta/main.yml | 11 ----------- tasks/host_vars.yml | 17 +++++++++++++++++ tasks/main.yml | 3 +++ templates/host_vars.yml.j2 | 5 +++++ vars/main.yml | 10 ++++++++++ 5 files changed, 35 insertions(+), 11 deletions(-) delete mode 100644 meta/main.yml create mode 100644 tasks/host_vars.yml create mode 100644 tasks/main.yml create mode 100644 templates/host_vars.yml.j2 diff --git a/meta/main.yml b/meta/main.yml deleted file mode 100644 index e59bf48..0000000 --- a/meta/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -dependencies: - - role: static_host_vars - static_host_vars_filename: partitions - static_host_vars: - hard_disks: "{{ hard_disks }}" - mdraid_devices: "{{ mdraid_devices }}" - dmcrypt_devices: "{{ dmcrypt_devices }}" - volume_groups: "{{ volume_groups }}" - logical_volumes: "{{ logical_volumes }}" - filesystems: "{{ filesystems }}" diff --git a/tasks/host_vars.yml b/tasks/host_vars.yml new file mode 100644 index 0000000..6f176a5 --- /dev/null +++ b/tasks/host_vars.yml @@ -0,0 +1,17 @@ +--- + +- name: host_vars directory + local_action: + file + path={{ playbook_dir }}/host_vars/{{inventory_hostname}} + state=directory + +- name: host_vars file + local_action: + template + src=host_vars.yml.j2 + dest={{ playbook_dir }}/host_vars/{{inventory_hostname}}/{{_host_vars_filename}}.yml + +- name: include host_vars + include_vars: + dir: "{{ playbook_dir }}/host_vars/{{inventory_hostname}}/" diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..902dbab --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,3 @@ +--- + +- include: host_vars.yml diff --git a/templates/host_vars.yml.j2 b/templates/host_vars.yml.j2 new file mode 100644 index 0000000..88e52a5 --- /dev/null +++ b/templates/host_vars.yml.j2 @@ -0,0 +1,5 @@ +{% if ("host_vars/"+inventory_hostname+'/'+_host_vars_filename+'.yml') | is_file %} +{{ _host_vars_default | combine( lookup('file','host_vars/'+inventory_hostname+'/'+_host_vars_filename+'.yml') | from_yaml ) | combine( _host_vars ) | to_nice_yaml }} +{% else %} +{{ _host_vars_default | combine( _host_vars ) | to_nice_yaml }} +{% endif %} diff --git a/vars/main.yml b/vars/main.yml index 3519406..16f4dc6 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,13 @@ +_host_vars_filename: partitions +_host_vars: + hard_disks: "{{ hard_disks }}" + mdraid_devices: "{{ mdraid_devices }}" + dmcrypt_devices: "{{ dmcrypt_devices }}" + volume_groups: "{{ volume_groups }}" + logical_volumes: "{{ logical_volumes }}" + filesystems: "{{ filesystems }}" + + filesystem_uuid_namespace: "{{ lookup('pipe','uuid -v4') }}" _fs_uuid_root: "{{ lookup('pipe','uuid -v5 '+filesystem_uuid_namespace+' root') }}"