parent
0c1a8a95f2
commit
5d0f56ce38
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: See if k3s file exists
|
- name: See if k3s file exists
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: /usr/local/bin/k3s
|
path: /usr/local/bin/k3s
|
||||||
register: k3s_status
|
register: k3s_status
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
- name: Install K3s on the secondary servers
|
- name: Install K3s on the secondary servers
|
||||||
when: not k3s_status.stat.exists
|
when: not k3s_status.stat.exists
|
||||||
command: |
|
ansible.builtin.command: |
|
||||||
/tmp/k3s_install.sh
|
/tmp/k3s_install.sh
|
||||||
environment:
|
environment:
|
||||||
K3S_URL: "https://{{ k3s.loadbalancer.ip }}:{{ k3s.loadbalancer.default_port }}"
|
K3S_URL: "https://{{ k3s.loadbalancer.ip }}:{{ k3s.loadbalancer.default_port }}"
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
- name: Wait for K3s to be installed
|
- name: Wait for K3s to be installed
|
||||||
when: (host.ip == k3s.server.ips[0] and (not k3s_status.stat.exists))
|
when: (host.ip == k3s.server.ips[0] and (not k3s_status.stat.exists))
|
||||||
async_status:
|
ansible.builtin.async_status:
|
||||||
jid: "{{ k3s_primary_install.ansible_job_id }}"
|
jid: "{{ k3s_primary_install.ansible_job_id }}"
|
||||||
register: k3s_primary_install_status
|
register: k3s_primary_install_status
|
||||||
until: k3s_primary_install_status.finished
|
until: k3s_primary_install_status.finished
|
||||||
|
@ -36,14 +36,15 @@
|
||||||
|
|
||||||
- name: Get K3s token from the first server
|
- name: Get K3s token from the first server
|
||||||
when: host.ip == k3s.server.ips[0]
|
when: host.ip == k3s.server.ips[0]
|
||||||
slurp:
|
ansible.builtin.slurp:
|
||||||
src: /var/lib/rancher/k3s/server/node-token
|
src: /var/lib/rancher/k3s/server/node-token
|
||||||
register: k3s_token
|
register: k3s_token
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Set fact on k3s.server.ips[0]
|
- name: Set fact on k3s.server.ips[0]
|
||||||
when: host.ip == k3s.server.ips[0]
|
when: host.ip == k3s.server.ips[0]
|
||||||
ansible.builtin.set_fact: k3s_token="{{ k3s_token['content'] | b64decode | trim }}"
|
ansible.builtin.set_fact:
|
||||||
|
k3s_token: "{{ k3s_token['content'] | b64decode | trim }}"
|
||||||
|
|
||||||
- name: Install K3s on the secondary servers
|
- name: Install K3s on the secondary servers
|
||||||
when: (host.ip != k3s.server.ips[0] and (not k3s_status.stat.exists))
|
when: (host.ip != k3s.server.ips[0] and (not k3s_status.stat.exists))
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
---
|
---
|
||||||
- include_tasks: requirements.yml
|
- name: Install dependencies
|
||||||
- include_tasks: installation.yml
|
ansible.builtin.include_tasks: requirements.yml
|
||||||
|
- name: Install k3s
|
||||||
|
ansible.builtin.include_tasks: installation.yml
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Restart nginx
|
- name: Restart nginx
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: restarted
|
state: restarted
|
||||||
become: true
|
become: true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Template the nginx config file with dynamic upstreams
|
- name: Template the nginx config file with dynamic upstreams
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: templates/nginx.conf.j2
|
src: templates/nginx.conf.j2
|
||||||
dest: "{{ nginx_config_path }}"
|
dest: "{{ nginx_config_path }}"
|
||||||
owner: root
|
owner: root
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
k3s_server_ips: "{{ k3s.server.ips }}"
|
k3s_server_ips: "{{ k3s.server.ips }}"
|
||||||
|
|
||||||
- name: Enable nginx
|
- name: Enable nginx
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: nginx
|
name: nginx
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Install Nginx
|
- name: Install Nginx
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- nginx-full
|
- nginx-full
|
||||||
state: present
|
state: present
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
---
|
---
|
||||||
- include_tasks: installation.yml
|
- name: Installation
|
||||||
- include_tasks: configuration.yml
|
ansible.builtin.include_tasks: installation.yml
|
||||||
|
- name: Configure
|
||||||
|
ansible.builtin.include_tasks: configuration.yml
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
- name: Determine latest GitHub release (local)
|
- name: Determine latest GitHub release (local)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
uri:
|
ansible.builtin.uri:
|
||||||
url: "https://api.github.com/repos/prometheus/node_exporter/releases/{{ version }}"
|
url: "https://api.github.com/repos/prometheus/node_exporter/releases/{{ version }}"
|
||||||
body_format: json
|
body_format: json
|
||||||
register: _github_release
|
register: _github_release
|
||||||
|
@ -9,10 +9,10 @@
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
- name: Set version
|
- name: Set version
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
tag: "{{ _github_release.json.tag_name
|
tag: "{{ _github_release.json.tag_name
|
||||||
| regex_replace('^v?([0-9\\.]+)$', '\\1') }}"
|
| regex_replace('^v?([0-9\\.]+)$', '\\1') }}"
|
||||||
|
|
||||||
- name: Set download_url
|
- name: Set download_url
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
download_url: "https://github.com/prometheus/node_exporter/releases/download/v{{ tag }}/node_exporter-{{ tag }}.linux-{{ go_arch }}.tar.gz"
|
download_url: "https://github.com/prometheus/node_exporter/releases/download/v{{ tag }}/node_exporter-{{ tag }}.linux-{{ go_arch }}.tar.gz"
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
---
|
---
|
||||||
- name: Download/Extract "{{ download_url }}"
|
- name: Download/Extract "{{ download_url }}"
|
||||||
unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "{{ download_url }}"
|
src: "{{ download_url }}"
|
||||||
dest: /tmp/
|
dest: /tmp/
|
||||||
remote_src: true
|
remote_src: true
|
||||||
mode: 755
|
mode: "755"
|
||||||
|
|
||||||
- name: Move node_exporter into path
|
- name: Move node_exporter into path
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "/tmp/node_exporter-{{ tag }}.linux-{{ go_arch }}/node_exporter"
|
src: "/tmp/node_exporter-{{ tag }}.linux-{{ go_arch }}/node_exporter"
|
||||||
dest: "{{ bin_path }}"
|
dest: "{{ bin_path }}"
|
||||||
mode: 755
|
mode: "755"
|
||||||
remote_src: true
|
remote_src: true
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Create node_exporter user.
|
- name: Create node_exporter user.
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: node_exporter
|
name: node_exporter
|
||||||
shell: /sbin/nologin
|
shell: /sbin/nologin
|
||||||
state: present
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Copy the node_exporter systemd unit file.
|
- name: Copy the node_exporter systemd unit file.
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: node_exporter.service.j2
|
src: node_exporter.service.j2
|
||||||
dest: /etc/systemd/system/node_exporter.service
|
dest: /etc/systemd/system/node_exporter.service
|
||||||
mode: 0644
|
mode: "644"
|
||||||
become: true
|
become: true
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
- include_tasks: get_version.yml
|
- name: Get Version
|
||||||
- include_tasks: install.yml
|
ansible.builtin.include_tasks: get_version.yml
|
||||||
- include_tasks: systemd.yml
|
- name: Install
|
||||||
|
ansible.builtin.include_tasks: install.yml
|
||||||
|
- name: Setup Service
|
||||||
|
ansible.builtin.include_tasks: systemd.yml
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Ensure node_exporter is running and enabled at boot.
|
- name: Ensure node_exporter is running and enabled at boot.
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: node_exporter
|
name: node_exporter
|
||||||
state: started
|
state: started
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Restart postgres
|
- name: Restart postgres
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: postgresql
|
name: postgresql
|
||||||
state: restarted
|
state: restarted
|
||||||
become: true
|
become: true
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Install ansible dependencies
|
- name: Install ansible dependencies
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ ansible_dependencies }}"
|
name: "{{ ansible_dependencies }}"
|
||||||
become: true
|
become: true
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
- name: Install postgres
|
- name: Install postgres
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ postgres_packages }}"
|
name: "{{ postgres_packages }}"
|
||||||
state: present
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Start and enable the service
|
- name: Start and enable the service
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
name: postgresql
|
name: postgresql
|
||||||
state: started
|
state: started
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
---
|
---
|
||||||
- include_tasks: ansible_deps.yml
|
- name: Install ansible dependencies for this role
|
||||||
- include_tasks: installation.yml
|
ansible.builtin.include_tasks: ansible_deps.yml
|
||||||
- include_tasks: configuration.yml
|
- name: Install postgres
|
||||||
|
ansible.builtin.include_tasks: installation.yml
|
||||||
|
- name: Configure Database
|
||||||
|
ansible.builtin.include_tasks: configuration.yml
|
||||||
|
|
Loading…
Reference in New Issue