aboutsummaryrefslogtreecommitdiff
path: root/tasks/main.yml
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-03-05 22:33:19 -0500
committerMitch Riedstra <mitch@riedstra.us>2019-03-05 22:33:19 -0500
commita436d3d340a96d473c2b7c7a29cebd54367a60b4 (patch)
tree13059eb336ce2bd4ec25ec97c47d27e45006ee09 /tasks/main.yml
downloadprometheus-a436d3d340a96d473c2b7c7a29cebd54367a60b4.tar.gz
prometheus-a436d3d340a96d473c2b7c7a29cebd54367a60b4.tar.xz
Initial
Diffstat (limited to 'tasks/main.yml')
-rw-r--r--tasks/main.yml85
1 files changed, 85 insertions, 0 deletions
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..10648a0
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,85 @@
+- name: Setup Prometheus User
+ user:
+ name: "{{prometheus_user}}"
+ home: "{{prometheus_home_dir}}"
+ state: present
+- set_fact: "prometheus_extract_dir=prometheus-{{prometheus_version}}.{{prometheus_os}}-{{prometheus_architecture}}"
+- name: Create configuration directory
+ file:
+ state: directory
+ dest: "{{prometheus_home_dir}}/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_home_dir}}/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_home_dir}}/{{prometheus_extract_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_extract_dir}}'
+ dest: '{{prometheus_home_dir}}/prometheus'
+ force: yes
+- name: Link configuration files
+ file:
+ state: link
+ src: '../conf/{{item}}'
+ dest: '{{prometheus_home_dir}}/prometheus/{{item}}'
+ force: yes
+ loop:
+ - prometheus.yml
+- name: Write prometheus template
+ template:
+ src: prometheus/prometheus.yml
+ 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"