Skip to content

Commit

Permalink
Merge pull request #2 from infrawatch/lmadsen-support-operator
Browse files Browse the repository at this point in the history
Add controls for writing templates to disk
  • Loading branch information
leifmadsen authored Aug 19, 2020
2 parents 3157987 + b07f0e5 commit 942ab95
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 20 deletions.
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions defaults/main/00_misc_vars.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions defaults/main/write_prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
collectd_plugin_write_prometheus_port: 9103
52 changes: 32 additions & 20 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_generate_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
5 changes: 5 additions & 0 deletions templates/write_prometheus.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
LoadPlugin write_prometheus

<Plugin write_prometheus>
Port "{{ collectd_plugin_write_prometheus_port }}"
</Plugin>

0 comments on commit 942ab95

Please sign in to comment.