mirror of
https://github.com/mii443/prometheus-android-exporter.git
synced 2025-12-03 19:18:26 +00:00
ansible playbook finished
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
[android-prometheus-exporter-target-server]
|
[android_prometheus_exporter_target_server]
|
||||||
139.144.68.186
|
143.42.59.63 ansible_ssh_private_key_file=../credentials/key
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# run this playbook against new linux server
|
# run this playbook against new linux server
|
||||||
|
|
||||||
- name: Install example server stack for prometheus-exporter-android
|
- name: Install example server stack for prometheus-exporter-android
|
||||||
hosts: android-prometheus-exporter-target-server
|
hosts: android_prometheus_exporter_target_server
|
||||||
remote_user: root
|
remote_user: root
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
@@ -46,10 +46,20 @@
|
|||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Install or update pip
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name:
|
||||||
|
- python-pip
|
||||||
|
- python3-pip
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Install 'docker' package from pip for ansible commands
|
- name: Install 'docker' package from pip for ansible commands
|
||||||
ansible.builtin.pip:
|
ansible.builtin.pip:
|
||||||
name: docker
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
|
loop:
|
||||||
|
- docker
|
||||||
|
- docker-compose
|
||||||
|
|
||||||
- name: Enable and start docker service
|
- name: Enable and start docker service
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
@@ -66,15 +76,20 @@
|
|||||||
|
|
||||||
- name: Reset ssh connection for user group changes to take place
|
- name: Reset ssh connection for user group changes to take place
|
||||||
ansible.builtin.meta: reset_connection
|
ansible.builtin.meta: reset_connection
|
||||||
when: add_docker_group.changed
|
|
||||||
|
- name: Install passlib for new user creation
|
||||||
|
ansible.builtin.pip:
|
||||||
|
name: passlib
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Create new user
|
- name: Create new user
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ new_user_name }}"
|
name: "{{ new_user_name }}"
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
|
update_password: on_create
|
||||||
groups: wheel
|
groups: wheel
|
||||||
append: true
|
append: true
|
||||||
password: "{{ new_user_password | password_hash('sha512', general.password_salt) }}"
|
password: "{{ new_user_password | password_hash('sha512') }}"
|
||||||
|
|
||||||
- name: Execute the following as the new user
|
- name: Execute the following as the new user
|
||||||
become: true
|
become: true
|
||||||
@@ -82,26 +97,35 @@
|
|||||||
tags: configuration
|
tags: configuration
|
||||||
block:
|
block:
|
||||||
- name: Copy configuration files
|
- name: Copy configuration files
|
||||||
ansible.posix.synchronize:
|
ansible.builtin.copy:
|
||||||
src: ./configuration
|
src: ./configuration
|
||||||
dest: "{{ '/home/' + new_user_name + '/configuration' }}"
|
dest: "{{ '/home/' + new_user_name + '/' }}"
|
||||||
owner: "{{ new_user_name }}"
|
owner: "{{ new_user_name }}"
|
||||||
group: "{{ new_user_name }}"
|
group: "{{ new_user_name }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
force: true
|
force: true
|
||||||
register: config_files
|
register: config_files
|
||||||
|
|
||||||
|
- name: Copy docker-compose.yaml
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: ./docker-compose.yaml
|
||||||
|
dest: "{{ '/home/' + new_user_name + '/docker-compose.yaml' }}"
|
||||||
|
owner: "{{ new_user_name }}"
|
||||||
|
group: "{{ new_user_name }}"
|
||||||
|
mode: 0644
|
||||||
|
force: true
|
||||||
|
register: compose_file
|
||||||
|
|
||||||
- name: Pull images
|
- name: Pull images
|
||||||
community.docker.docker_compose:
|
community.docker.docker_compose:
|
||||||
pull: true
|
pull: true
|
||||||
recreate: always
|
|
||||||
project_src: "{{ '/home/' + new_user_name }}"
|
project_src: "{{ '/home/' + new_user_name }}"
|
||||||
|
|
||||||
- name: Start docker compose
|
- name: Start docker compose
|
||||||
community.docker.docker_compose:
|
community.docker.docker_compose:
|
||||||
state: present
|
state: present
|
||||||
project_src: "{{ '/home/' + new_user_name }}"
|
project_src: "{{ '/home/' + new_user_name }}"
|
||||||
restarted: "{{ config_files.changed | bool }}"
|
restarted: "{{ (config_files.changed | bool) or (compose_file.changed | bool) }}"
|
||||||
|
|
||||||
- name: Create docker compose systemd service
|
- name: Create docker compose systemd service
|
||||||
block:
|
block:
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- common-network
|
- common-network
|
||||||
volumes:
|
volumes:
|
||||||
- grafana-data:/var/lib/grafana
|
- grafana-data:/var/lib/grafana #TODO add grafana datasource prometheus by default
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
container_name: nginx
|
container_name: nginx
|
||||||
image: nginx:1.23.4
|
image: nginx:1.23.4
|
||||||
volumes:
|
volumes:
|
||||||
- ${PWD}/configuration/nginx.conf:/etc/nginx/nginx.conf
|
- ./configuration/nginx.conf:/etc/nginx/nginx.conf
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000 # grafana port
|
- 3000:3000 # grafana port
|
||||||
- 8080:8080 # pushprox port
|
- 8080:8080 # pushprox port
|
||||||
@@ -44,7 +44,7 @@ services:
|
|||||||
image: bitnami/prometheus:2.43.0
|
image: bitnami/prometheus:2.43.0
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
volumes:
|
volumes:
|
||||||
- ${PWD}/configuration/prometheus.yaml:/etc/prometheus/prometheus.yml
|
- ./configuration/prometheus.yaml:/etc/prometheus/prometheus.yml
|
||||||
networks:
|
networks:
|
||||||
- common-network
|
- common-network
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user