Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit d25d2ab

Browse files
Merge pull request #31 from arruzk/version
Specify a particular version of clickhouse
2 parents 7b0bc73 + d197a48 commit d25d2ab

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Any issues and pr are welcome.
66

77
Role Variables
88
--------------
9+
F: You can specify a particular version (or `*` for the latest). Please note that downgrade isn't supported.
10+
```yaml
11+
clickhouse_version: "19.11.3.11"
12+
```
913
1014
F: You can manage listen ports
1115
```yaml

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
# defaults file for clickhouse
33

4+
clickhouse_version: "*"
5+
46
#Flag for using with requirements check
57
clickhouse_supported: no
68
#Type of installation (package,source)

tasks/install_apt.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
- name: Install by APT | Package installation
2424
apt:
25-
name: "{{ item }}"
26-
state: latest
25+
name: "{{ item }}={{ clickhouse_version }}"
26+
state: present
27+
force: yes
2728
with_items: "{{ clickhouse_package }}"
28-
become: true
29+
become: true

tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
debug: var=clickhouse_rt_isinstalled.rc
1414

1515
- include: install_apt.yml
16-
when: ansible_pkg_mgr == 'apt' and clickhouse_setup == 'package' and clickhouse_rt_isinstalled.rc !=0 and clickhouse_remove|bool == False
16+
when: ansible_pkg_mgr == 'apt' and clickhouse_setup == 'package' and (clickhouse_rt_isinstalled.rc !=0 or not clickhouse_is_required_version) and clickhouse_remove|bool == False
1717
tags: [install]
1818

1919
- include: remove_apt.yml

tasks/precheck.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@
1616
when: ansible_pkg_mgr == 'apt' and clickhouse_setup == 'package'
1717
changed_when: False
1818
check_mode: no
19+
20+
- name: Requirements check | Check if Clickhouse is installed and has required version
21+
shell: dpkg-query --showformat='${Version}' --show "{{ item }}"
22+
register: clickhouse_rt_versions_tmp
23+
ignore_errors: yes
24+
changed_when: False
25+
check_mode: no
26+
with_items: "{{ clickhouse_package }}"
27+
- set_fact:
28+
clickhouse_rt_versions: "{{ clickhouse_rt_versions_tmp['results'] | map(attribute='stdout') | list }}"
29+
- set_fact:
30+
clickhouse_is_required_version: "{{ clickhouse_version == '*' or (clickhouse_rt_versions | unique | count == 1 and clickhouse_rt_versions[0] == clickhouse_version) }}"

0 commit comments

Comments
 (0)