-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftware.yml
138 lines (119 loc) · 4.26 KB
/
software.yml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
- name: Add host to dblab_group
hosts: localhost
gather_facts: false
tasks:
- name: Add {{ dblab_host }} to dblab_group
ansible.builtin.add_host:
name: "{{ dblab_host }}"
groups: dblab_group
changed_when: false
when: dblab_host is defined and dblab_host | length > 1
tags: always
# add the path to the temporary ssh key if it is used
- name: Set facts for dblab_group
hosts: dblab_group
gather_facts: false
tasks:
- name: "Set variable: ansible_ssh_private_key_file"
ansible.builtin.set_fact:
ansible_ssh_private_key_file: "~{{ lookup('env', 'USER') }}/.ssh/{{ hostvars['localhost']['dblab_tmp_ssh_key_name'] }}"
when:
- hostvars['localhost']['ssh_key_name'] is defined
- hostvars['localhost']['ssh_key_name'] == hostvars['localhost']['dblab_tmp_ssh_key_name']
tags: always
- name: Deploy and configure DBLab Engine software
hosts: dblab_group
become: true
become_method: sudo
gather_facts: true
any_errors_fatal: true
environment: "{{ proxy_env | default({}) }}"
vars:
minimal_ansible_version: 2.11.0
minimal_dblab_engine_version: 3.4.0
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: vars/main.yml
tags: always
- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tags: always
- name: Checking ansible version
ansible.builtin.fail:
msg: "Ansible version must be {{ minimal_ansible_version }} or higher"
delegate_to: localhost
when: ansible_version.full is version(minimal_ansible_version, '<')
tags: always
- name: Checking DBLab Engine version
ansible.builtin.fail:
msg: "DBLab Engine version must be {{ minimal_dblab_engine_version }} or higher"
when: dblab_engine_version | regex_replace('^v', '') | regex_replace('-rc.+$', '') is version(minimal_dblab_engine_version, '<')
tags: always
- name: Checking Linux distribution
ansible.builtin.fail:
msg: "{{ ansible_distribution }} is not supported"
when: ansible_distribution not in os_valid_distributions
tags: always
- name: Checking version of OS Linux
ansible.builtin.fail:
msg: "{{ ansible_distribution_version }} of {{ ansible_distribution }} is not supported"
when: ansible_distribution_version is version_compare(os_minimum_versions[ansible_distribution], '<')
tags: always
- name: Confirm that necessary variables are set
ansible.builtin.debug:
msg:
- "Some required variables have empty values."
- "Specify values for variables: 'platform_project_name', 'platform_org_key'."
- "For questions, contact Postgres.ai: https://postgres.ai/contact."
failed_when: platform_project_name | length < 1 or platform_org_key | length < 1
when: platform_project_name | length < 1 or platform_org_key | length < 1
tags: always
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
register: apt_status
until: apt_status is success
delay: 10
retries: 3
when: ansible_os_family == "Debian"
- name: Ensure gnupg, gpg-agent, and apt-transport-https packages are present
ansible.builtin.apt:
pkg:
- gnupg
- gpg-agent
- apt-transport-https
state: present
register: apt_status
until: apt_status is success
delay: 10
retries: 3
when: ansible_os_family == "Debian"
- name: Ensure 'set backupcopy=yes' is in ~/.vimrc
ansible.builtin.lineinfile:
path: "~{{ username }}/.vimrc"
line: 'set backupcopy=yes'
create: true # This will create the file if it doesn't exist
owner: "{{ username }}"
group: "{{ username }}"
mode: "0600"
roles:
# Prepare system
- role: authorized-keys
- role: add-repository
- role: packages
- role: zpool
# Configure and start DBLab Engine
- role: dblab-engine
- role: dblab-cli
# Joe Bot
- role: joe-bot
when: joe_bot_install | bool
# Proxy server
- role: proxy
# Monitoring
- role: netdata
# finish (connection info)
- role: deploy-finish
...