Skip to content

Commit

Permalink
Add guards to the role for multi-node clouds
Browse files Browse the repository at this point in the history
This change adds a missing endif block in the cgroup template and sets a
default for the nova virt type should it be undefined. This change also
adds guards around the haproxy and scripts task files so that both local
scripts to this role and upstream osa scripts can be used at the same
time. The sudo template was updated to ensure success by making sure
required variables are defined.

Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
  • Loading branch information
cloudnull committed Mar 23, 2018
1 parent 4f1d469 commit ea9d82f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tasks/telegraf_post_install_haproxy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
- name: Get stats socket path
shell: gawk '/stats socket/ {print $3}' /etc/haproxy/haproxy.cfg
register: haproxy_stats_socket
failed_when: false
tags:
- telegraf_client-config

- name: Add telegraf to haclient group
user: name=telegraf append=yes groups=haclient
when:
- haproxy_stats_socket.rc == 0
- inventory_hostname in groups['network_all']
- ansible_virtualization_role != 'host' # Already run as root
notify:
Expand All @@ -20,6 +22,8 @@
dest: "{{ item.dest }}"
owner: "root"
group: "root"
when:
- haproxy_stats_socket.rc == 0
with_items:
- { src: "haproxy.conf.j2", dest: "/etc/telegraf/telegraf.d/haproxy.conf" }
notify:
Expand Down
1 change: 1 addition & 0 deletions tasks/telegraf_post_install_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
with_dict: "{{ telegraf_openstack_scripts }}"
when:
- item.value.when_group | bool
- item.value.plugin_source_path is defined
- item.value.group == inventory_hostname or inventory_hostname in item.value.group | default([])
tags:
- telegraf_client-config
Expand Down
3 changes: 2 additions & 1 deletion templates/cgroup.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"/sys/fs/cgroup/memory/system.slice/keepalived.service/",
#"/sys/fs/cgroup/blkio/system.slice/keepalived.service/"
{% endif %}
{% if inventory_hostname in groups['compute_hosts'] and nova_virt_type == 'lxd' %}
{% if inventory_hostname in groups['compute_hosts'] and nova_virt_type | default('kvm') == 'lxd' %}
# Compute hosts with LXD
"/sys/fs/cgroup/cpuacct/lxc/",
"/sys/fs/cgroup/memory/lxc/",
#"/sys/fs/cgroup/blkio/lxc/",
{% endif %}
{% if inventory_hostname in groups['compute_hosts'] %}
# Compute hosts common
"/sys/fs/cgroup/cpuacct/neutron.slice/",
Expand Down
2 changes: 2 additions & 0 deletions templates/telegraf.sudo.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
{% set run_commands = [] %}
{% for key, value in telegraf_openstack_scripts.items() %}
{% if value.when_group | bool and (value.group == inventory_hostname or inventory_hostname in value.group | default([])) %}
{% if value.sudoers_entry is defined %}
{% set _ = run_commands.extend(value.sudoers_entry) %}
{% endif %}
{% endif %}
{% endfor %}

Expand Down

0 comments on commit ea9d82f

Please sign in to comment.