Skip to content

Commit

Permalink
Merge pull request #51 from idealista/refactor/#50
Browse files Browse the repository at this point in the history
Refactor/#50
  • Loading branch information
ultraheroe authored Mar 27, 2023
2 parents c4fa4c3 + 375aeb7 commit 76395ac
Show file tree
Hide file tree
Showing 10 changed files with 499 additions and 272 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

## [Unreleased](https://github.com/idealista/clickhouse_role/tree/develop)

## [3.3.3(https://github.com/idealista/clickhouse_role/tree/3.3.3 (2023-03-27)

### :repeat: Updated

- [#50](https://github.com/idealista/clickhouse_role/issues/50) [REFACTOR] Adecuate service file changes to default CH version

### :hammer_and_wrench: Fixed

- Some typos and quotation

## [3.3.2](https://github.com/idealista/clickhouse_role/tree/3.3.2 (2023-01-18)

### :heavy_plus_sign: Added
Expand Down
715 changes: 460 additions & 255 deletions Pipfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clickhouse_role_manage_grants: False
## Service options
# Documentation
clickhouse_documentation_link: https://clickhouse.tech/docs/en/
clickhouse_environment_file: /etc/default/clickhouse

# Set to restart-clickhouse if you need a complete restart of the service i.e. changing listeners config
clickhouse_handler_on_config_change: "Restart-clickhouse"
Expand Down
1 change: 1 addition & 0 deletions molecule/default/group_vars/clickhouse_group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ clickhouse_version: 22.8.8.3
clickhouse_release_type: lts

# Clickhouse role management
clickhouse_install_db: True
clickhouse_role_manage_users: True
clickhouse_role_manage_roles: True
clickhouse_role_manage_databases: True
Expand Down
8 changes: 4 additions & 4 deletions molecule/default/tests/test_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ file:
group: {{ clickhouse_group }}
exists: true
filetype: directory
{{ clickhouse_config_directory }}/{{ clickhouse_config_file_name }}:
"{{ clickhouse_config_directory }}/{{ clickhouse_config_file_name }}":
owner: {{ clickhouse_user }}
group: {{ clickhouse_group }}
exists: true
filetype: file
{{ clickhouse_config_directory }}/{{ clickhouse_users_file_name }}:
"{{ clickhouse_config_directory }}/{{ clickhouse_users_file_name }}":
owner: {{ clickhouse_user }}
group: {{ clickhouse_group }}
exists: true
Expand Down Expand Up @@ -74,14 +74,14 @@ http:
http://localhost:8123?query=SHOW+USERS:
status: 200
timeout: 10000
body: ["admin","default","readonly","Bunta","Takumi"]
body: ["admin", "default", "readonly", "Bunta", "Takumi"]
username: {{ clickhouse_admin_user }}
password: {{ clickhouse_admin_password }}
skip: false
http://localhost:8123?query=SHOW+DATABASES:
status: 200
timeout: 10000
body: ["system","default","ProjectD","ex_racing","racing"]
body: ["system", "default", "ProjectD", "ex_racing", "racing"]
username: {{ clickhouse_admin_user }}
password: {{ clickhouse_admin_password }}
skip: false
Expand Down
2 changes: 1 addition & 1 deletion tasks/config/perms_and_privs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
\""
changed_when: False
when: clickhouse_custom_grants_previous_cleanup
# no_log: True
no_log: True
tags:
- clickhouse_grants
- select
Expand Down
2 changes: 1 addition & 1 deletion tasks/config/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- SQL_driven

- name: CLICKHOUSE | Drop users (SQL-driven)
command: "clickhouse-client -u {{ clickhouse_admin_user }} --password {{ clickhouse_admin_password }} -q \"DROP USER IF EXISTS {{ item }} ;\""
command: "clickhouse-client -u {{ clickhouse_admin_user }} --password {{ clickhouse_admin_password }} -q \"DROP USER IF EXISTS '{{ item }}' ;\""
with_items: "{{ clickhouse_existing_sql_users.stdout_lines }}"
when:
- clickhouse_existing_sql_users is defined
Expand Down
12 changes: 12 additions & 0 deletions tasks/install-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
name: "{{ clickhouse_group }}"
system: yes
state: present
tags: [clickhouse_install]

- name: CLICKHOUSE | Ensure clickhouse user
user:
Expand All @@ -13,6 +14,7 @@
system: yes
shell: /usr/sbin/nologin
createhome: no
tags: [clickhouse_install]

- name: CLICKHOUSE | Ensure base directory exist
file:
Expand All @@ -22,28 +24,33 @@
group: "{{ clickhouse_group }}"
mode: "{{ clickhouse_base_directory_mode }}"
become: true
tags: [clickhouse_install]

- name: CLICKHOUSE | Update repositories cache and install apt-transport-https, dirmngr packages
apt:
name: "{{ clickhouse_prerequisite_repos }}"
state: present
tags: [clickhouse_install]

- name: CLICKHOUSE | Be sure key is present
apt_key:
keyserver: "{{ clickhouse_deb_keyserver }}"
id: "{{ clickhouse_deb_keyid }}"
state: present
tags: [clickhouse_install]

- name: CLICKHOUSE | Add clickhouse apt repository (deb)
apt_repository:
repo: "{{ clickhouse_deb_repo }}"
state: present
tags: [clickhouse_install]

- name: CLICKHOUSE | Be sure clickhouse packages are installed (apt)
apt:
name: "{{ clickhouse_packages }}"
state: present
update_cache: true
tags: [clickhouse_install]

- name: CLICKHOUSE | Ensure user files and access control directories exist
file:
Expand All @@ -56,6 +63,7 @@
- "{{ clickhouse_access_control_directory }}"
- "{{ clickhouse_user_files_directory }}"
become: true
tags: [clickhouse_install]

- name: CLICKHOUSE | Ensure needed config directories exist
file:
Expand All @@ -69,6 +77,7 @@
- "{{ clickhouse_config_directory_config_d }}"
- "{{ clickhouse_config_directory_users_d }}"
become: true
tags: [clickhouse_install]

- name: CLICKHOUSE | Ensure needed tmp directories exist
file:
Expand All @@ -78,6 +87,7 @@
group: "{{ clickhouse_group }}"
mode: "{{ clickhouse_tmp_directory_mode }}"
become: true
tags: [clickhouse_install]

- name: CLICKHOUSE | Ensure needed log directory exist
file:
Expand All @@ -87,10 +97,12 @@
group: "{{ clickhouse_group }}"
mode: "{{ clickhouse_log_directory_mode }}"
become: true
tags: [clickhouse_install]

- name: CLICKHOUSE | Clickhouse extra packages are installed (apt)
apt:
name: "{{ clickhouse_packages_extra }}"
state: present
update_cache: true
when: clickhouse_packages_extra is defined
tags: [clickhouse_install]
2 changes: 1 addition & 1 deletion templates/DDL/USER.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE USER IF NOT EXISTS {{ item.name }}{% if item.cluster is defined %} ON CLUSTER {{item.cluster }}{% endif %}
CREATE USER IF NOT EXISTS '{{ item.name }}'{% if item.cluster is defined %} ON CLUSTER {{item.cluster }}{% endif %}
{% if item.ldap_server is defined %} IDENTIFIED WITH ldap SERVER '{{ item.ldap_server }}'{% elif item.kerberos is defined %} IDENTIFIED WITH kerberos {% if item.kerberos != '' %}REALM '{{ item.kerberos }}'{% endif %}{% elif item.password is defined %} IDENTIFIED WITH {{ item.password_type | default("sha256_password") | lower }}{% if item.password is defined and item.password_type is not defined or (item.password is defined and item.password_type | upper != 'NO_PASSWORD') %} BY '{{ item.password}}'{% endif %}{% else %} NOT IDENTIFIED{% endif %}
{% if item.networks is defined %} HOST {% for host in item.networks %}{{ host }}{{ ", " if not loop.last else "" }}{% endfor %}{% endif %}
{% if item.role is defined %} DEFAULT ROLE {% for role in item.role %}{{ role }}{{ ", " if not loop.last else "" }}{% endfor %}{% endif %}
Expand Down
18 changes: 8 additions & 10 deletions templates/clickhouse-server.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ After=time-sync.target network-online.target
Wants=time-sync.target

[Service]
PrivateTmp= {{ clickhouse_private_tmp }}
Type=simple
User={{ clickhouse_user }}
Group={{ clickhouse_group }}
Restart=always
RestartSec=30
PrivateTmp= {{ clickhouse_private_tmp }}
RuntimeDirectory={{ clickhouse_service }}
LimitNOFILE={{ clickhouse_limit_no_file }}

ExecStart=/usr/bin/{{ clickhouse_service }} --config={{ clickhouse_config_directory }}/{{ clickhouse_config_file_name }} --pid-file=/run/clickhouse-server/{{ clickhouse_service }}.pid

StandardOutput={{ clickhouse_log_output }}
StandardError={{ clickhouse_log_output }}
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
Restart=always
RestartSec=30

EnvironmentFile=-{{ clickhouse_environment_file }}
LimitCORE=infinity
LimitNOFILE={{ clickhouse_limit_no_file }}
CapabilityBoundingSet=CAP_NET_ADMIN CAP_IPC_LOCK CAP_SYS_NICE CAP_NET_BIND_SERVICE

StandardOutput={{ clickhouse_log_output }}
StandardError={{ clickhouse_log_output }}

[Install]
WantedBy=multi-user.target

0 comments on commit 76395ac

Please sign in to comment.