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