jaredledvina/sensu-go-ansible

more documentation around deploying clustered mode

Closed this issue · 6 comments

Firstly, this is a great role. It's worked as expected. It would be good if the docs included an example of a playbook for a clustered deployment. I'm guessing I need to use the variable sensu_go_configs_override: {}, but I have no idea if that's accurate. I'm going to test now... stay tuned.

Hey @acrawly,

Thanks! I'll admit, I haven't been pushing many features/improvements here so, happy to hear it's working out. Additionally, I've only ever run a single Sensu Go node, so I don't know offhand what config options are needed to set that up. However, using sensu_go_configs_override: and setting whatever is needed is probably a great start.

Let me know if you figure out the settings needed and if there's any work needed in this role to support clustered mode, happy to work on that.

Finally, Sensu hired a team to create https://github.com/sensu/sensu-go-ansible, it'll be officially supported (whereas this one is just something I try to do on my free time). Do check that out as well!

I've got this working, but since v5.16, I'm having issues handling the environment variables for the default username and password. When I have that working, I'll do a pull request to add a section to the readme or something.

I haven't had time to do a fork, pull, etc. That said, here is the working copy of the code:

roles:
    - geerlingguy.ntp
    - role: jaredledvina.sensu_go_ansible
      vars:
        sensu_go_repos_overrides:
          yum:
            rpm: https://packagecloud.io/sensu/stable/el/7/x86_64
            rpm-src: https://packagecloud.io/sensu/stable/el/7/SRPMS
        sensu_go_community_repos_overrides:
          yum:
            rpm: https://packagecloud.io/sensu/community/el/7/x86_64
            rpm-src: https://packagecloud.io/sensu/community/el/7/SRPMS
        sensu_go_configs_override: 
          backend:
            cleanup_example: true
            config:
              etcd-advertise-client-urls: "http://{{ inventory_hostname }}:{{ etcd_client_port }}"
              etcd-listen-client-urls: "http://{{ inventory_hostname }}:{{ etcd_client_port }}"
              etcd-listen-peer-urls: "http://0.0.0.0:{{ etcd_server_listening_port }}"
              etcd-initial-cluster: "{% for ip in sensu_server_ip_list.ips %}{{ etcd_hostname_prefix }}{{ip}}=http://{{ip}}:{{ etcd_server_listening_port }},{% endfor %}"
              etcd-initial-advertise-peer-urls: "http://{{ inventory_hostname }}:2380"
              etcd-initial-cluster-state: "new"
              etcd-initial-cluster-token: ""
              etcd-name: "{{ etcd_hostname_prefix }}{{ inventory_hostname }}"
          agent:
            config:
              backend-url:
                - ws://sensu-agent.your-server.com:8081
      when: sensu_server_ip_list is defined

sensu_server_ips looks like this:

---
  ips:
  {% for ip in server_ips %}
  - "{{ ip }}"
  {% endfor %}

Here's how I populate the list of IPs:

- name: save IPs of servers for Sensu config
    set_fact: 
      server_ip: "{{ item.private_ip }}"
    loop: "{{ zone_a_instance.instances }}"
    register: server_ips_result

  - name: make a list
    set_fact: 
      server_ips: "{{ server_ips_result.results | map(attribute='ansible_facts.server_ip') | list }}"
    loop: "{{ zone_a_instance.instances }}"

  - name: save list of IPs to disk for later use
    template:
      dest: ../templates/sensu/server_ips.yml
      src: "../templates/sensu/server_ips.yml.j2"

Lastly, I modified the role under tasks/config/backend.yml to look like this:

- name: Initialize sensu backend
  command: sensu-backend init
  run_once: true
  environment:
    SENSU_BACKEND_CLUSTER_ADMIN_USERNAME: "{{ vault_sensu_default_username }}"
    SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD: "{{ vault_sensu_default_password }}"

Hey @acrawly ,

That's great! I'll try to find some time to PR the above and test it as well. Thanks so much!

https://github.com/jaredledvina/sensu-go-ansible/releases/tag/3.0.0 includes work to ensure we initialize the backend.