diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2019-09-28 21:06:36 -0400 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2019-09-28 21:06:36 -0400 |
| commit | 377df0b6841bf61f128c8b9098cc1bf6d506a5b7 (patch) | |
| tree | 789bc2d3dc46cf1da0a4c62b8e6f49b1ad7fb83b /tasks | |
| parent | 4d82dba8e2ce90364cb899a293c75ba37cbb791f (diff) | |
| download | prometheus-377df0b6841bf61f128c8b9098cc1bf6d506a5b7.tar.gz prometheus-377df0b6841bf61f128c8b9098cc1bf6d506a5b7.tar.xz | |
Update the role, add some more documentation, and a license
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/main.yml | 43 | ||||
| -rw-r--r-- | tasks/main.yml.bak | 58 | ||||
| -rw-r--r-- | tasks/runit.yml | 17 | ||||
| -rw-r--r-- | tasks/systemd.yml | 9 |
4 files changed, 34 insertions, 93 deletions
diff --git a/tasks/main.yml b/tasks/main.yml index 10648a0..3f2c2a4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -27,7 +27,7 @@ - name: Extract Prometheus shell: | if ! [ -e "{{prometheus_home_dir}}/{{prometheus_extract_dir}}" ] ; then - sudo su - '{{prometheus_user}}' -c 'tar xzf prometheus-{{prometheus_version}}.tgz' + su - '{{prometheus_user}}' -c 'tar xzf prometheus-{{prometheus_version}}.tgz' fi changed_when: false - name: Link prometheus directory @@ -46,40 +46,13 @@ - prometheus.yml - name: Write prometheus template template: - src: prometheus/prometheus.yml + src: '{{prometheus_template_source}}' dest: '{{prometheus_home_dir}}/conf/prometheus.yml' owner: '{{prometheus_user}}' mode: '0600' -- name: Write Systemd Unite - template: - src: prometheus/systemd.unit - dest: /etc/systemd/system/prometheus.service - when: ansible_facts['distribution'].lower() == "ubuntu" -- name: 'Enable Prometheus [Ubuntu]' - systemd: - enabled: yes - daemon_reload: yes - name: prometheus - when: ansible_facts['distribution'].lower() == "ubuntu" -- name: Create Runit Directory - file: - state: directory - dest: /etc/sv.local/prometheus - owner: root - group: adm - mode: '0755' - when: ansible_facts['distribution'].lower() == "void" -- name: Write runit service - template: - src: prometheus/runit/run - dest: /etc/sv.local/prometheus/run - owner: root - group: adm - mode: '0755' - when: ansible_facts['distribution'].lower() == "void" -- name: Enable Runit service - file: - state: link - src: /etc/sv.local/prometheus - dest: /var/service/prometheus - when: ansible_facts['distribution'].lower() == "void" +- name: Run Runit Specific tasks + include_tasks: systemd.yml + when: ansible_facts['distribution'].lower() == "ubuntu" or ansible_facts['distribution'].lower() == "centos" +- name: Run Runit Specific tasks + include_tasks: runit.yml + when: ansible_facts['distribution'].lower() == "void" or ansible_facts['distribution'].lower() == "alpine" diff --git a/tasks/main.yml.bak b/tasks/main.yml.bak deleted file mode 100644 index 587dfc5..0000000 --- a/tasks/main.yml.bak +++ /dev/null @@ -1,58 +0,0 @@ -- name: Setup Prometheus User - user: - name: "{{prometheus_user}}" - home: "{{prometheus_home_dir}}" - state: present -- name: Get User home directory - shell: "awk -F: '{if($1==\"{{prometheus_user}}\"){print $6}}' /etc/passwd" - changed_when: false - register: get_home_command_output -- set_fact: "prometheus_user_home={{get_home_command_output['stdout']}}" -- set_fact: "prometheus_dir=prometheus-{{prometheus_version}}.{{prometheus_os}}-{{prometheus_architecture}}" -- name: Create configuration directory - file: - state: directory - dest: "{{prometheus_user_home}}/conf" - mode: '0700' - owner: "{{prometheus_user}}" -- name: Create Data directory - file: - state: directory - dest: "{{prometheus_data_dir}}" - mode: '0700' - owner: "{{prometheus_user}}" -- name: Download Prometheus - get_url: - url: "{{prometheus_url}}" - dest: "{{prometheus_user_home}}/prometheus-{{prometheus_version}}.tgz" - mode: '0600' - owner: "{{prometheus_user}}" -# There's a bug in become_user that doesn't set permissions on the temp directory -# which is asinine when my user has sudo persmissions. -- name: Extract Prometheus - shell: | - if ! [ -e "{{prometheus_user_home}}/{{prometheus_dir}}" ] ; then - sudo su - '{{prometheus_user}}' -c 'tar xzf prometheus-{{prometheus_version}}.tgz' - fi - changed_when: false -- name: Link prometheus directory - file: - state: link - src: '{{prometheus_dir}}' - dest: '{{prometheus_user_home}}/prometheus' - force: yes -- name: Link configuration files - file: - state: link - src: '../conf/{{item}}' - dest: '{{prometheus_user_home}}/prometheus/{{item}}' - force: yes - loop: - - prometheus.yml -- name: Write prometheus template - template: - src: prometheus/prometheus.yml - dest: '{{prometheus_user_home}}/conf/prometheus.yml' - owner: '{{prometheus_user}}' - mode: '0600' - diff --git a/tasks/runit.yml b/tasks/runit.yml new file mode 100644 index 0000000..d8bf8d4 --- /dev/null +++ b/tasks/runit.yml @@ -0,0 +1,17 @@ +- name: Create Runit Directory + file: + state: directory + dest: /etc/sv/prometheus + owner: root + mode: '0755' +- name: Write runit service + template: + src: prometheus/runit/run + dest: /etc/sv/prometheus/run + owner: root + mode: '0755' +- name: Enable Runit service + file: + state: link + src: /etc/sv/prometheus + dest: /var/service/prometheus diff --git a/tasks/systemd.yml b/tasks/systemd.yml new file mode 100644 index 0000000..031f036 --- /dev/null +++ b/tasks/systemd.yml @@ -0,0 +1,9 @@ +- name: Write Systemd Unit + template: + src: prometheus/systemd.unit + dest: /etc/systemd/system/prometheus.service +- name: 'Enable Prometheus [Systemd]' + systemd: + enabled: yes + daemon_reload: yes + name: prometheus |
