From b1510ea09e92e1f4476701803e7251e0b90d6950 Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Tue, 18 Aug 2020 23:29:57 -0400 Subject: [PATCH 1/3] Add controls for writing templates to disk Also add write_prometheus template support --- defaults/main/00_misc_vars.yml | 3 ++ defaults/main/write_prometheus.yml | 1 + tasks/main.yml | 52 ++++++++++++++++++------------ templates/write_prometheus.conf.j2 | 5 +++ 4 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 defaults/main/write_prometheus.yml create mode 100644 templates/write_prometheus.conf.j2 diff --git a/defaults/main/00_misc_vars.yml b/defaults/main/00_misc_vars.yml index 99d1070..1e01aa5 100644 --- a/defaults/main/00_misc_vars.yml +++ b/defaults/main/00_misc_vars.yml @@ -1,5 +1,8 @@ --- # defaults file for test-role + +# write templates to disk +templates_generate_to_disk: true # These defaults mirror the defaults set for corresponding parameters in TripleO keystone_region: "regionOne" #NOTE(efoley) TripleO does not provide defaults for these values in the template, they are probably passed in from elsewhere. diff --git a/defaults/main/write_prometheus.yml b/defaults/main/write_prometheus.yml new file mode 100644 index 0000000..2602ba4 --- /dev/null +++ b/defaults/main/write_prometheus.yml @@ -0,0 +1 @@ +collectd_plugin_write_prometheus_port: 9103 diff --git a/tasks/main.yml b/tasks/main.yml index f41b3fe..da34fba 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,26 +6,38 @@ - debug: var: collectd_plugins -- name: "Remove file" - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ collectd_conf_output_dir }}/" - - "{{ collectd_conf_output_dir }}/../collectd.conf" +- block: + - name: "Remove file" + file: + path: "{{ item }}" + state: absent + with_items: + - "{{ collectd_conf_output_dir }}/" + - "{{ collectd_conf_output_dir }}/../collectd.conf" -- name: "Create config dir" - file: - path: "{{ collectd_conf_output_dir }}/" - state: directory + - name: "Create config dir" + file: + path: "{{ collectd_conf_output_dir }}/" + state: directory -- name: "Create core collectd config" - template: - src: collectd.conf.j2 - dest: "{{ collectd_conf_output_dir }}/../collectd.conf" + - name: "Create core collectd config" + template: + src: collectd.conf.j2 + dest: "{{ collectd_conf_output_dir }}/../collectd.conf" -- name: "Create plugin config files" - template: - src: "{{ item }}.conf.j2" - dest: "{{ collectd_conf_output_dir }}/{{ item }}.conf" - loop: "{{ collectd_plugins }}" + - name: "Create plugin config files" + template: + src: "{{ item }}.conf.j2" + dest: "{{ collectd_conf_output_dir }}/{{ item }}.conf" + loop: "{{ collectd_plugins }}" + when: templates_genenerate_to_disk + +- block: + - name: "Create core collectd config" + set_fact: "{{ item }}={{ lookup('template', item + '.conf.j2') }}" + loop: "{{ collectd_plugins }}" + + - debug: + var: "{{ item }}" + loop: "{{ collectd_plugins }}" + when: not templates_generate_to_disk diff --git a/templates/write_prometheus.conf.j2 b/templates/write_prometheus.conf.j2 new file mode 100644 index 0000000..9c48194 --- /dev/null +++ b/templates/write_prometheus.conf.j2 @@ -0,0 +1,5 @@ +LoadPlugin write_prometheus + + + Port "{{ collectd_plugin_write_prometheus_port }}" + From 5130fa60c787302e15526823987ae39a8e9ac49f Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Tue, 18 Aug 2020 23:43:27 -0400 Subject: [PATCH 2/3] Fix typo --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index da34fba..a49f621 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -30,7 +30,7 @@ src: "{{ item }}.conf.j2" dest: "{{ collectd_conf_output_dir }}/{{ item }}.conf" loop: "{{ collectd_plugins }}" - when: templates_genenerate_to_disk + when: templates_generate_to_disk - block: - name: "Create core collectd config" From b07f0e5d3bc145758f55b677d4ee2839d7257a89 Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Wed, 19 Aug 2020 10:40:39 -0400 Subject: [PATCH 3/3] Add .travis CI yaml back --- .travis.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file