blob: 587dfc5ff16d364a4b1b3a7c318cb47e72d4229c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
- 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'
|