@ -0,0 +1,2 @@ | |||
*.retry | |||
*.log |
@ -0,0 +1,5 @@ | |||
[defaults] | |||
log_path=ansible.log | |||
nocows = 1 | |||
hash_behaviour = merge | |||
deprecation_warnings=False |
@ -0,0 +1,10 @@ | |||
--- | |||
clickhouse_version: "18.16.0" | |||
clickhouse_zookeeper: | |||
- host: zk-0.clustering.myserver.ru | |||
index: 1 | |||
- host: zk-1.clustering.myserver.ru | |||
index: 2 | |||
- host: zk-2.clustering.myserver.ru | |||
index: 3 | |||
@ -0,0 +1,25 @@ | |||
--- | |||
clickhouse_macroses: | |||
cluster_1_shard: s0 | |||
cluster_1_replica: r0 | |||
clickhouse_remote_servers: | |||
cluster_1: | |||
- servers: | |||
- host: ch1.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD | |||
- host: ch3.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD | |||
# ััะพั dict ัะพะปัะบะพ ะดะปั ะทะฝะฐัะตะฝะธะน ะฒะฝัััะธ ัะตะณะพะฒ! ะตัะปะธ ะฝัะถะฝะพ ะฟะพะฟัะฐะฒะธัั ะทะฝะฐัะตะฝะธะต | |||
# ะฐััะธะฑััะฐ ัะตะณะฐ, ัะพ ะฟัะธะดะตััั ะดะตะปะฐัั ะฒัะพัะพะน dict ะดะปั ะฐััะธะฑััะพะฒ | |||
clickhouse_config_tags: | |||
max_memory_usage: | |||
value: "64424509440" | |||
path: "/etc/clickhouse-server/users.xml" | |||
xpath: "/yandex/profiles/default/max_memory_usage" | |||
max_size_to_drop: | |||
value: "0" | |||
path: "/etc/clickhouse-server/config.xml" | |||
xpath: "/yandex/max_table_size_to_drop" |
@ -0,0 +1,13 @@ | |||
--- | |||
clickhouse_macroses: | |||
cluster_2_shard: s0 | |||
cluster_2_replica: r0 | |||
clickhouse_remote_servers: | |||
cluster_2: | |||
- servers: | |||
- host: ch2.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD | |||
- host: ch3.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD |
@ -0,0 +1,23 @@ | |||
--- | |||
clickhouse_macroses: | |||
cluster_1_shard: s0 | |||
cluster_1_replica: r1 | |||
cluster_2_shard: s0 | |||
cluster_2_replica: r1 | |||
clickhouse_remote_servers: | |||
cluster_1: | |||
- servers: | |||
- host: ch1.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD | |||
- host: ch3.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD | |||
cluster_2: | |||
- servers: | |||
- host: ch2.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD | |||
- host: ch3.dbpool.myserver.ru | |||
user: default | |||
password: b0mbas$w0rD |
@ -0,0 +1,18 @@ | |||
zk-0.clustering.myserver.ru ansible_host=zk-0.clustering.myserver.ru ansible_user=root | |||
zk-1.clustering.myserver.ru ansible_host=zk-1.clustering.myserver.ru ansible_user=root | |||
zk-2.clustering.myserver.ru ansible_host=zk-2.clustering.myserver.ru ansible_user=root | |||
ch1.dbpool.myserver.ru ansible_host=ch1.dbpool.myserver.ru ansible_user=root | |||
ch2.dbpool.myserver.ru ansible_host=ch2.dbpool.myserver.ru ansible_user=root | |||
ch3.dbpool.myserver.ru ansible_host=ch3.dbpool.myserver.ru ansible_user=root | |||
[zookeepers] | |||
zk-0.clustering.myserver.ru | |||
zk-1.clustering.myserver.ru | |||
zk-2.clustering.myserver.ru | |||
[clickhouse] | |||
ch1.dbpool.myserver.ru | |||
ch2.dbpool.myserver.ru | |||
ch3.dbpool.myserver.ru | |||
@ -0,0 +1,26 @@ | |||
--- | |||
- name: Install or update python2 required by Ansible | |||
hosts: all | |||
ignore_errors: yes | |||
vars: | |||
ansible_python_interpreter: /usr/bin/python3 | |||
roles: | |||
- python2 | |||
- name: Upgrade pip to last version | |||
hosts: all | |||
ignore_errors: yes | |||
- upgrade_pip | |||
- preinstall | |||
- name: Install and configure Zookeeper | |||
hosts: zookeepers | |||
roles: | |||
- zookeeper | |||
- name: Install and configure Clickhouse | |||
hosts: clickhouse | |||
roles: | |||
- clickhouse | |||
@ -0,0 +1,3 @@ | |||
- src: idealista.zookeeper-role | |||
version: 1.3.0 | |||
name: zookeeper |
@ -0,0 +1,9 @@ | |||
--- | |||
clickhouse_version: "18.12.17" | |||
clickhouse_max_connections: "4096" | |||
clickhouse_max_concurrent_queries: "100" | |||
clickhouse_zookeeper_distributed_ddl_path: "/clickhouse/task_queue/ddl" | |||
clickhouse_max_table_size_to_drop: "53687091200" | |||
clickhouse_macroses: [] | |||
clickhouse_zookeeper: [] | |||
clickhouse_remote_servers: [] |
@ -0,0 +1,15 @@ | |||
--- | |||
- name: "Start ClickHouse" | |||
systemd: | |||
name: clickhouse-server | |||
state: started | |||
enabled: yes | |||
tags: ["clickhouse", "clickhouse-install"] | |||
- name: "Restart Clickhouse" | |||
become: true | |||
systemd: | |||
name: clickhouse-server | |||
state: restarted | |||
daemon_reload: yes | |||
tags: ["clickhouse", "clickhouse-configure"] |
@ -0,0 +1,33 @@ | |||
--- | |||
- name: Create config from template | |||
template: | |||
src: "config-{{ clickhouse_version }}.xml.j2" | |||
dest: /etc/clickhouse-server/config.xml | |||
owner: clickhouse | |||
group: clickhouse | |||
mode: 0644 | |||
backup: yes | |||
become: yes | |||
notify: "Restart Clickhouse" | |||
tags: ["clickhouse", "clickhouse-configure"] | |||
- name: Create config with includes from template | |||
template: | |||
src: "metrika-{{ clickhouse_version }}.xml.j2" | |||
dest: /etc/metrika.xml | |||
owner: clickhouse | |||
group: clickhouse | |||
mode: 0644 | |||
backup: yes | |||
become: yes | |||
tags: ["clickhouse", "clickhouse-configure"] | |||
- name: Set tags in config files | |||
become: yes | |||
xml: | |||
path: "{{ item.value.path }}" | |||
xpath: "{{ item.value.xpath }}" | |||
value: "{{ item.value.value }}" | |||
with_dict: "{{ clickhouse_config_tags }}" | |||
when: clickhouse_config_tags is defined | |||
tags: ["clickhouse", "clickhouse-configure"] |
@ -0,0 +1,41 @@ | |||
--- | |||
- name: Add Clickhouse repository key | |||
apt_key: | |||
keyserver: "keyserver.ubuntu.com" | |||
id: "E0C56BD4" | |||
state: "present" | |||
become: true | |||
tags: ["clickhouse", "clickhouse-install"] | |||
- name: Add Clickhouse repository | |||
apt_repository: | |||
repo: "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" | |||
filename: "clickhouse.list" | |||
state: "present" | |||
become: true | |||
tags: ["clickhouse", "clickhouse-install"] | |||
- name: Update APT | |||
apt: | |||
update_cache: true | |||
tags: ["clickhouse", "clickhouse-install"] | |||
- name: Install Clickhouse | |||
apt: | |||
name: ["clickhouse-common-static={{ clickhouse_version }}", "clickhouse-server={{ clickhouse_version }}", "clickhouse-client={{ clickhouse_version }}"] | |||
state: "present" | |||
become: true | |||
notify: "Start ClickHouse" | |||
tags: ["clickhouse", "clickhouse-install"] | |||
- name: "Start Clickhouse (If it wasn't running)" | |||
systemd: | |||
name: clickhouse-server | |||
state: restarted | |||
enabled: yes | |||
become: yes | |||
tags: ["clickhouse", "clickhouse-install"] | |||
- name: "Configure Clickhouse" | |||
include_tasks: "configure.yml" | |||
tags: ["clickhouse", "clickhouse-configure"] |
@ -0,0 +1,76 @@ | |||
<?xml version="1.0"?> | |||
<yandex> | |||
<logger> | |||
<level>trace</level> | |||
<log>/var/log/clickhouse-server/clickhouse-server.log</log> | |||
<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog> | |||
<size>1000M</size> | |||
<count>10</count> | |||
</logger> | |||
{% if inventory_hostname is defined %} | |||
<display_name>{{ inventory_hostname }}</display_name> | |||
{% endif %} | |||
<http_port>8123</http_port> | |||
<tcp_port>9000</tcp_port> | |||
<http_server_default_response><![CDATA[<html ng-app="SMI2"><head><base href="http://ui.tabix.io/"></head><body><div ui-view="" class="content-ui"></div><script src="http://loader.tabix.io/master.js"></script></body></html>]]></http_server_default_response> | |||
<interserver_http_port>9009</interserver_http_port> | |||
{% if inventory_hostname is defined %} | |||
<interserver_http_host>{{ inventory_hostname }}</interserver_http_host> | |||
{% endif %} | |||
<listen_host>::</listen_host> | |||
<max_connections>{{ clickhouse_max_connections|default('4096') }}</max_connections> | |||
<keep_alive_timeout>3</keep_alive_timeout> | |||
<max_concurrent_queries>{{ clickhouse_max_concurrent_queries|default('100') }}</max_concurrent_queries> | |||
<insert_distributed_sync>1</insert_distributed_sync> | |||
<insert_distributed_timeout>0</insert_distributed_timeout> | |||
<uncompressed_cache_size>8589934592</uncompressed_cache_size> | |||
<mark_cache_size>5368709120</mark_cache_size> | |||
<path>/var/lib/clickhouse/</path> | |||
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path> | |||
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path> | |||
<users_config>users.xml</users_config> | |||
<default_profile>default</default_profile> | |||
<default_database>default</default_database> | |||
<remote_servers incl="clickhouse_remote_servers"></remote_servers> | |||
<zookeeper incl="zookeeper-servers" optional="true" /> | |||
<macros incl="macros" optional="true" /> | |||
<builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval> | |||
<max_session_timeout>3600</max_session_timeout> | |||
<default_session_timeout>60</default_session_timeout> | |||
<log_queries>0</log_queries> | |||
<query_log> | |||
<database>system</database> | |||
<table>query_log</table> | |||
<partition_by>toYYYYMM(event_date)</partition_by> | |||
<flush_interval_milliseconds>7500</flush_interval_milliseconds> | |||
</query_log> | |||
<part_log> | |||
<database>system</database> | |||
<table>part_log</table> | |||
<flush_interval_milliseconds>7500</flush_interval_milliseconds> | |||
</part_log> | |||
<dictionaries_config>*_dictionary.xml</dictionaries_config> | |||
<compression incl="clickhouse_compression"></compression> | |||
<distributed_ddl> | |||
<path>{{ clickhouse_zookeeper_distributed_ddl_path|default('/clickhouse/task_queue/ddl') }}</path> | |||
</distributed_ddl> | |||
<max_table_size_to_drop>{{ clickhouse_max_table_size_to_drop|default('53687091200') }}</max_table_size_to_drop> | |||
<format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path> | |||
</yandex> |
@ -0,0 +1,76 @@ | |||
<?xml version="1.0"?> | |||
<yandex> | |||
<logger> | |||
<level>trace</level> | |||
<log>/var/log/clickhouse-server/clickhouse-server.log</log> | |||
<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog> | |||
<size>1000M</size> | |||
<count>10</count> | |||
</logger> | |||
{% if inventory_hostname is defined %} | |||
<display_name>{{ inventory_hostname }}</display_name> | |||
{% endif %} | |||
<http_port>8123</http_port> | |||
<tcp_port>9000</tcp_port> | |||
<http_server_default_response><![CDATA[<html ng-app="SMI2"><head><base href="http://ui.tabix.io/"></head><body><div ui-view="" class="content-ui"></div><script src="http://loader.tabix.io/master.js"></script></body></html>]]></http_server_default_response> | |||
<interserver_http_port>9009</interserver_http_port> | |||
{% if inventory_hostname is defined %} | |||
<interserver_http_host>{{ inventory_hostname }}</interserver_http_host> | |||
{% endif %} | |||
<listen_host>::</listen_host> | |||
<max_connections>{{ clickhouse_max_connections|default('4096') }}</max_connections> | |||
<keep_alive_timeout>3</keep_alive_timeout> | |||
<max_concurrent_queries>{{ clickhouse_max_concurrent_queries|default('100') }}</max_concurrent_queries> | |||
<insert_distributed_sync>1</insert_distributed_sync> | |||
<insert_distributed_timeout>0</insert_distributed_timeout> | |||
<uncompressed_cache_size>8589934592</uncompressed_cache_size> | |||
<mark_cache_size>5368709120</mark_cache_size> | |||
<path>/var/lib/clickhouse/</path> | |||
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path> | |||
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path> | |||
<users_config>users.xml</users_config> | |||
<default_profile>default</default_profile> | |||
<default_database>default</default_database> | |||
<remote_servers incl="clickhouse_remote_servers"></remote_servers> | |||
<zookeeper incl="zookeeper-servers" optional="true" /> | |||
<macros incl="macros" optional="true" /> | |||
<builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval> | |||
<max_session_timeout>3600</max_session_timeout> | |||
<default_session_timeout>60</default_session_timeout> | |||
<log_queries>0</log_queries> | |||
<query_log> | |||
<database>system</database> | |||
<table>query_log</table> | |||
<partition_by>toYYYYMM(event_date)</partition_by> | |||
<flush_interval_milliseconds>7500</flush_interval_milliseconds> | |||
</query_log> | |||
<part_log> | |||
<database>system</database> | |||
<table>part_log</table> | |||
<flush_interval_milliseconds>7500</flush_interval_milliseconds> | |||
</part_log> | |||
<dictionaries_config>*_dictionary.xml</dictionaries_config> | |||
<compression incl="clickhouse_compression"></compression> | |||
<distributed_ddl> | |||
<path>{{ clickhouse_zookeeper_distributed_ddl_path|default('/clickhouse/task_queue/ddl') }}</path> | |||
</distributed_ddl> | |||
<max_table_size_to_drop>{{ clickhouse_max_table_size_to_drop|default('53687091200') }}</max_table_size_to_drop> | |||
<format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path> | |||
</yandex> |
@ -0,0 +1,44 @@ | |||
<?xml version="1.0"?> | |||
<yandex> | |||
{% if clickhouse_remote_servers|length > 0 %} | |||
<clickhouse_remote_servers> | |||
{% for cluster_name, cluster in clickhouse_remote_servers.items() %} | |||
<{{ cluster_name }}> | |||
{% for shard in cluster %} | |||
<shard> | |||
<weight>{{ shard.weight|default('1') }}</weight> | |||
<internal_replication>{{ shard.internal_replication|default('false') }}</internal_replication> | |||
{% for server in shard.servers %} | |||
<replica> | |||
<host>{{ server.host }}</host> | |||
<port>{{ server.port|default('9000') }}</port> | |||
</replica> | |||
{% endfor %} | |||
</shard> | |||
{% endfor %} | |||
</{{ cluster_name }}> | |||
{% endfor %} | |||
</clickhouse_remote_servers> | |||
{% endif %} | |||
{% if clickhouse_zookeeper|length > 0 %} | |||
<zookeeper-servers> | |||
{% for server in clickhouse_zookeeper %} | |||
<node index="{{ server.index }}"> | |||
<host>{{ server.host }}</host> | |||
<port>{{ server.port|default('2181') }}</port> | |||
</node> | |||
{% endfor %} | |||
</zookeeper-servers> | |||
{% endif %} | |||
{% if clickhouse_macroses|length > 0 %} | |||
<macros> | |||
{% for key, value in clickhouse_macroses.items() %} | |||
<{{ key }}>{{ value }}</{{ key }}> | |||
{% endfor %} | |||
</macros> | |||
{% endif %} | |||
</yandex> |
@ -0,0 +1,52 @@ | |||
<?xml version="1.0"?> | |||
<yandex> | |||
{% if clickhouse_remote_servers|length > 0 %} | |||
<clickhouse_remote_servers> | |||
{% for cluster_name, cluster in clickhouse_remote_servers.items() %} | |||
<{{ cluster_name }}> | |||
{% for shard in cluster %} | |||
<shard> | |||
<weight>{{ shard.weight|default('1') }}</weight> | |||
<internal_replication>{{ shard.internal_replication|default('false') }}</internal_replication> | |||
{% for server in shard.servers %} | |||
<replica> | |||
<host>{{ server.host }}</host> | |||
<port>{{ server.port|default('9000') }}</port> | |||
{% if server.user is defined %} | |||
<user>{{ server.user }}</user> | |||
{% endif %} | |||
{% if server.password is defined %} | |||
<password>{{ server.password }}</password> | |||
{% endif %} | |||
</replica> | |||
{% endfor %} | |||
</shard> | |||
{% endfor %} | |||
</{{ cluster_name }}> | |||
{% endfor %} | |||
</clickhouse_remote_servers> | |||
{% endif %} | |||
{% if clickhouse_zookeeper|length > 0 %} | |||
<zookeeper-servers> | |||
{% for server in clickhouse_zookeeper %} | |||
<node index="{{ server.index }}"> | |||
<host>{{ server.host }}</host> | |||
<port>{{ server.port|default('2181') }}</port> | |||
</node> | |||
{% endfor %} | |||
</zookeeper-servers> | |||
{% endif %} | |||
{% if clickhouse_macroses|length > 0 %} | |||
<macros> | |||
{% for key, value in clickhouse_macroses.items() %} | |||
<{{ key }}>{{ value }}</{{ key }}> | |||
{% endfor %} | |||
</macros> | |||
{% endif %} | |||
</yandex> |
@ -0,0 +1,7 @@ | |||
--- | |||
- name: Minimum packages for Debian-like | |||
apt: name="{{ item }}" state=present update_cache=yes | |||
become: yes | |||
with_items: | |||
- openjdk-11-jdk | |||
when: (ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian') |
@ -0,0 +1,10 @@ | |||
--- | |||
- name: Install python2 | |||
apt: name=python state=present | |||
- name: Install python pip | |||
apt: name=python-pip state=present | |||
- name: Install python python-setuptools | |||
apt: name=python-setuptools state=present | |||
@ -0,0 +1,5 @@ | |||
--- | |||
- name: Upgrade pip | |||
pip: | |||
name: pip | |||
extra_args: --upgrade |
@ -0,0 +1,74 @@ | |||
# Contributor Covenant Code of Conduct | |||
## Our Pledge | |||
In the interest of fostering an open and welcoming environment, we as | |||
contributors and maintainers pledge to making participation in our project and | |||
our community a harassment-free experience for everyone, regardless of age, body | |||
size, disability, ethnicity, gender identity and expression, level of experience, | |||
nationality, personal appearance, race, religion, or sexual identity and | |||
orientation. | |||
## Our Standards | |||
Examples of behavior that contributes to creating a positive environment | |||
include: | |||
* Using welcoming and inclusive language | |||
* Being respectful of differing viewpoints and experiences | |||
* Gracefully accepting constructive criticism | |||
* Focusing on what is best for the community | |||
* Showing empathy towards other community members | |||
Examples of unacceptable behavior by participants include: | |||
* The use of sexualized language or imagery and unwelcome sexual attention or | |||
advances | |||
* Trolling, insulting/derogatory comments, and personal or political attacks | |||
* Public or private harassment | |||
* Publishing others' private information, such as a physical or electronic | |||
address, without explicit permission | |||
* Other conduct which could reasonably be considered inappropriate in a | |||
professional setting | |||
## Our Responsibilities | |||
Project maintainers are responsible for clarifying the standards of acceptable | |||
behavior and are expected to take appropriate and fair corrective action in | |||
response to any instances of unacceptable behavior. | |||
Project maintainers have the right and responsibility to remove, edit, or | |||
reject comments, commits, code, wiki edits, issues, and other contributions | |||
that are not aligned to this Code of Conduct, or to ban temporarily or | |||
permanently any contributor for other behaviors that they deem inappropriate, | |||
threatening, offensive, or harmful. | |||
## Scope | |||
This Code of Conduct applies both within project spaces and in public spaces | |||
when an individual is representing the project or its community. Examples of | |||
representing a project or community include using an official project e-mail | |||
address, posting via an official social media account, or acting as an appointed | |||
representative at an online or offline event. Representation of a project may be | |||
further defined and clarified by project maintainers. | |||
## Enforcement | |||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | |||
reported by contacting the project team at [labs@idealista.com](mailto:labs@idealista.com). All | |||
complaints will be reviewed and investigated and will result in a response that | |||
is deemed necessary and appropriate to the circumstances. The project team is | |||
obligated to maintain confidentiality with regard to the reporter of an incident. | |||
Further details of specific enforcement policies may be posted separately. | |||
Project maintainers who do not follow or enforce the Code of Conduct in good | |||
faith may face temporary or permanent repercussions as determined by other | |||
members of the project's leadership. | |||
## Attribution | |||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | |||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html | |||
[homepage]: https://www.contributor-covenant.org |
@ -0,0 +1,100 @@ | |||
# Contributing to Idealista | |||
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1: | |||
The following is a set of guidelines for contributing to Idealista's repositories, which are hosted in the [Idealista Organization](https://github.com/idealista) on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. | |||
#### Table Of Contents | |||
[Code of Conduct](#code-of-conduct) | |||
[How Can I Contribute?](#how-can-i-contribute) | |||
* [Reporting Bugs](#reporting-bugs) | |||
* [Suggesting Enhancements](#suggesting-enhancements) | |||
* [Pull Requests](#pull-requests) | |||
* [Changelog](#changelog) | |||
[Styleguides](#styleguides) | |||
* [Git Commit Messages](#git-commit-messages) | |||
## Code of Conduct | |||
This project and everyone participating in it is governed by the [Idealista Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [labs@idealista.com](mailto:labs@idealista.com). | |||
## How Can I Contribute? | |||
### Reporting Bugs | |||
This section guides you through submitting a bug report for Idealista. Following these guidelines helps maintainers and the community understand your report :pencil:, reproduce the behavior :computer: :computer:, and find related reports :mag_right:. | |||
Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](ISSUE_TEMPLATE.md), the information it asks for helps us resolve issues faster. | |||
> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. | |||
#### Before Submitting A Bug Report | |||
* **Check the last version.** Check if you can reproduce the problem in the latest version of the project. | |||
* **Check the FAQ of the project** for a list of common questions and problems. | |||
* **Perform a [cursory search](https://github.com/issues?q=+is%3Aissue+user%3Aidealista)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one. | |||
#### How Do I Submit A (Good) Bug Report? | |||
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). Create an issue on the project repository and provide the following information by filling in [the template](ISSUE_TEMPLATE.md). | |||
Explain the problem and include additional details to help maintainers reproduce the problem: | |||
* **Use a clear and descriptive title** for the issue to identify the problem. | |||
* **Describe the exact steps which reproduce the problem** in as many details as possible. | |||
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior. | |||
* **Explain which behavior you expected to see instead and why.** | |||
### Suggesting Enhancements | |||
This section guides you through submitting an enhancement suggestion for Idealista, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:. | |||
Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in [the template](ISSUE_TEMPLATE.md), including the steps that you imagine you would take if the feature you're requesting existed. | |||
#### Before Submitting An Enhancement Suggestion | |||
* **Check the last version.** Check if you can reproduce the problem in the latest version of the project. | |||
* **Check the FAQ of the project** for a list of common questions and problems. | |||
* **Perform a [cursory search](https://github.com/issues?q=+is%3Aissue+user%3Aidealista)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. | |||
#### How Do I Submit A (Good) Enhancement Suggestion? | |||
Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). Create an issue on the project repository and provide the following information by filling in [the template](ISSUE_TEMPLATE.md): | |||
* **Use a clear and descriptive title** for the issue to identify the suggestion. | |||
* **Provide a step-by-step description of the suggested enhancement** in as many details as possible. | |||
* **Provide specific examples to demonstrate the steps**. | |||
* **Describe the current behavior** and **explain which behavior you expected to see instead** and why. | |||
* **Explain why this enhancement would be useful**. | |||
* **List some other text editors or applications where this enhancement exists.** | |||
* **Specify which version are you're using.** | |||
### Pull Requests | |||
* Fill in [the required template](PULL_REQUEST_TEMPLATE.md) | |||
* Any pull request should has **idealista:develop** as base branch. | |||
### Changelog | |||
Every project has a CHANGELOG.md file. Once your code is ready to be merged please fill the issue after the **Unreleased** section as explained: | |||
* For an enhancement, fill the issue after the **Added** subsection (create it if doesn't exists) | |||
* For a fixed bug, fill the issue after the **Fixed** subsection (create it if doesn't exists) | |||
* For an improvement, fill the issue after the **Changed** subsection (create it if doesn't exists) | |||
Then write the issue info this way: | |||
- *[#29](https://github.com/idealista/nginx-role/issues/29) Support debian stretch* @jmonterrubio | |||
## Styleguides | |||
### Git Commit Messages | |||
* Use the present tense ("Add feature" not "Added feature") | |||
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...") | |||
* Limit the first line to 72 characters or less | |||
* Reference issues and pull requests liberally after the first line |
@ -0,0 +1,36 @@ | |||
<!-- | |||
Have you read Idealista's Code of Conduct? By filling an Issue, you are expected to comply with it, | |||
including treating everyone with respect: https://github.com/idealista/idealista/blob/master/CODE_OF_CONDUCT.md | |||
--> | |||
### Prerequisites | |||
* [ ] Put an X between the brackets on this line if you have done all of the following: | |||
* Checked that your issue isn't already filled: https://github.com/issues?utf8=โ&q=is%3Aissue+user%3Aidealista | |||
* Checked that there is not already provided the described functionality | |||
### Description | |||
[Description of the issue] | |||
### Steps to Reproduce | |||
1. [First Step] | |||
2. [Second Step] | |||
3. [and so on...] | |||
**Expected behavior:** [What you expect to happen] | |||
**Actual behavior:** [What actually happens] | |||
**Reproduces how often:** [What percentage of the time does it reproduce?] | |||
### Versions | |||
The version/s you notice the behavior. | |||
### Additional Information | |||
Any additional information, configuration or data that might be necessary to reproduce the issue. |
@ -0,0 +1,26 @@ | |||
### Requirements | |||
* Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. | |||
* All new code requires tests to ensure against regressions | |||
* Remember to set **idealista:develop** as base branch; | |||
### Description of the Change | |||
<!-- | |||
We must be able to understand the design of your change from this description. If we can't get a good idea of what the code will be doing from the description here, the pull request may be closed at the maintainers' discretion. Keep in mind that the maintainer reviewing this PR may not be familiar with or have worked with the code here recently, so please walk us through the concepts. | |||
--> | |||
### Benefits | |||
<!-- What benefits will be realized by the code change? --> | |||
### Possible Drawbacks | |||
<!-- What are the possible side-effects or negative impacts of the code change? --> | |||
### Applicable Issues | |||
<!-- Enter any applicable Issues here --> |
@ -0,0 +1,12 @@ | |||
tests/playbook.retry | |||
tests/.cache | |||
tests/__pycache__ | |||
.molecule | |||
.vagrant | |||
.cache/ | |||
.pytest_cache | |||
.python-version | |||
*.iml | |||
.idea | |||
Pipfile | |||
Pipfile.lock |
@ -0,0 +1,15 @@ | |||
--- | |||
language: python | |||
python: "2.7.13" | |||
sudo: required | |||
services: | |||
- docker | |||
install: | |||
- pip install pipenv | |||
- pipenv install -r test-requirements.txt --python 2.7 | |||
script: | |||
- pipenv run molecule test | |||
notifications: | |||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
@ -0,0 +1,16 @@ | |||
extends: default | |||
rules: | |||
braces: | |||
max-spaces-inside: 1 | |||
level: error | |||
brackets: | |||
max-spaces-inside: 1 | |||
level: error | |||
line-length: disable | |||
# NOTE(retr0h): Templates no longer fail this lint rule. | |||
# Uncomment if running old Molecule templates. | |||
# truthy: disable | |||
ignore: | | |||
tests/ |
@ -0,0 +1,53 @@ | |||
# Change Log | |||
All notable changes to this project will be documented in this file. | |||
## [Unreleased] | |||
## [1.3.0](https://github.com/idealista/zookeeper-role/tree/1.3.0) (2018-12-05) | |||
[Full Changelog](https://github.com/idealista/zookeeper-role/compare/1.2.0...1.3.0) | |||
### Changed | |||
- *[#23](https://github.com/idealista/zookeeper-role/issues/23) Using ZooKeeper 3.4.13 as default version* @dortegau | |||
- *[#22](https://github.com/idealista/zookeeper-role/issues/22) Upgrading molecule version to 2.19.0 and Ansible to 2.5.3.0* @dortegau | |||
## [1.2.0](https://github.com/idealista/zookeeper-role/tree/1.2.0) (2018-06-04) | |||
[Full Changelog](https://github.com/idealista/zookeeper-role/compare/1.1.1...1.2.0) | |||
### Changed | |||
- *[#19](https://github.com/idealista/zookeeper-role/issues/19) Upgrade ZooKeeper version to 3.4.12* @eskabetxe | |||
- *Upgrade idealista.java-role to 3.0.0* @eskabetxe | |||
## [1.1.1](https://github.com/idealista/zookeeper-role/tree/1.1.1) (2018-03-05) | |||
[Full Changelog](https://github.com/idealista/zookeeper-role/compare/1.1.0...1.1.1) | |||
### Fixed | |||
- *[#12](https://github.com/idealista/zookeeper-role/issues/12) Expose service using tcp4 by default and ensuring that remote JMX access is enabled* @dortegau | |||
- *Remove upstart script to easy enable systemd service* @jmonterrubio | |||
## [1.1.0](https://github.com/idealista/zookeeper-role/tree/1.1.0) (2017-05-04) | |||
[Full Changelog](https://github.com/idealista/zookeeper-role/compare/1.0.3...1.1.0) | |||
### Added | |||
- *[#6](https://github.com/idealista/zookeeper-role/issues/6) Added JMX* @jmonterrubio | |||
### Changed | |||
- *Some variable redefinition* @jmonterrubio | |||
### Fixed | |||
- *Remove upstart script to easy enable systemd service* @jmonterrubio | |||
## [1.0.3](https://github.com/idealista/zookeeper-role/tree/1.0.3) (2016-12-23) | |||
### Fixed | |||
- *[#1](https://github.com/idealista/zookeeper-role/issues/1) Enable service by default* @jmonterrubio | |||
## [1.0.2](https://github.com/idealista/zookeeper-role/tree/1.0.2) (2016-12-21) | |||
### Fixed | |||
- *Update docs and refactor tasks* @jmonterrubio | |||
## [1.0.1](https://github.com/idealista/zookeeper-role/tree/1.0.1) (2016-11-18) | |||
### Fixed | |||
- *Fix problem with ansible unarchive* @jmonterrubio | |||
## [1.0.0](https://github.com/idealista/zookeeper-role/tree/1.0.0) (2016-10-26) | |||
### Added | |||
- *First commit* @jmonterrubio |
@ -0,0 +1,88 @@ | |||
Apache License | |||
Version 2.0, January 2004 | |||
http://www.apache.org/licenses/ | |||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |||
1. Definitions. | |||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. | |||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. | |||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. | |||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. | |||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. | |||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. | |||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). | |||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. | |||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." | |||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. | |||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. | |||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. | |||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: | |||
You must give any other recipients of the Work or Derivative Works a copy of this License; and | |||
You must cause any modified files to carry prominent notices stating that You changed the files; and | |||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and | |||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. | |||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. | |||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. | |||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. | |||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. | |||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. | |||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. | |||
END OF TERMS AND CONDITIONS | |||
APPENDIX: How to apply the Apache License to your work | |||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. | |||
Copyright [yyyy] [name of copyright owner] | |||
Licensed under the Apache License, Version 2.0 (the "License"); | |||
you may not use this file except in compliance with the License. | |||
You may obtain a copy of the License at | |||
http://www.apache.org/licenses/LICENSE-2.0 | |||
Unless required by applicable law or agreed to in writing, software | |||
distributed under the License is distributed on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
/** | |||
* Copyright Idealista S.A.U. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ |
@ -0,0 +1,107 @@ | |||
 | |||
# Apache ZooKeeper Ansible role [](https://travis-ci.org/idealista/zookeeper-role) | |||
This ansible role installs an Apache ZooKeeper service in a debian environment. | |||
- [Getting Started](#getting-started) | |||
- [Prerequisities](#prerequisities) | |||
- [Installing](#installing) | |||
- [Usage](#usage) | |||
- [Testing](#testing) | |||
- [Built With](#built-with) | |||
- [Versioning](#versioning) | |||
- [Authors](#authors) | |||
- [License](#license) | |||
- [Contributing](#contributing) | |||
- [Acknowledgments](#acknowledgments) | |||
## Getting Started | |||
These instructions will get you a copy of the role for your ansible playbook. Once launched, it will install an Apache ZooKeeper server. | |||
### Prerequisities | |||
Ansible 2.5.3.0 version installed. | |||
Molecule 2.19.0 version installed. | |||
Inventory destination should be a Debian environment. | |||
Notice that automatically java is installed as dependency. | |||
For testing purposes, [Molecule](https://molecule.readthedocs.io/) with [Docker](https://www.docker.com/) as driver | |||
### Installing | |||
Create or add to your roles dependency file (e.g requirements.yml): | |||
``` | |||
- src: idealista.zookeeper-role | |||
version: 1.3.0 | |||
name: zookeeper | |||
``` | |||
Install the role with ansible-galaxy command: | |||
``` | |||
ansible-galaxy install -p roles -r requirements.yml -f | |||
``` | |||
Use in a playbook: | |||
``` | |||
--- | |||
- hosts: someserver | |||
roles: | |||
- { | |||
role: zookeeper | |||
} | |||
``` | |||
## Usage | |||
To set multiple versions | |||
``` | |||
zookeeper_hosts: | |||
- host: zookeeper1 | |||
id: 1 | |||
- host: zookeeper2 | |||
id: 2 | |||
- host: zookeeper3 | |||
id: 3 | |||
``` | |||
## Testing | |||
```sh | |||
$ pipenv install -r test-requirements.txt --python 2.7 | |||
$ pipenv run molecule test | |||
``` | |||
## Built With | |||
 | |||
## Versioning | |||
For the versions available, see the [tags on this repository](https://github.com/idealista/zookeeper-role/tags). | |||
Additionaly you can see what change in each version in the [CHANGELOG.md](CHANGELOG.md) file. | |||
## Authors | |||
* **Idealista** - *Work with* - [idealista](https://github.com/idealista) | |||
See also the list of [contributors](https://github.com/idealista/zookeeper-role/contributors) who participated in this project. | |||
## License | |||
 | |||
This project is licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license - see the [LICENSE](LICENSE) file for details. | |||
## Contributing | |||
Please read [CONTRIBUTING.md](.github/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. |
@ -0,0 +1,60 @@ | |||
--- | |||
## General | |||
zookeeper_version: 3.4.13 | |||
## Service options | |||
# Owner | |||
zookeeper_user: zookeeper | |||
zookeeper_group: zookeeper | |||
# start on boot | |||
zookeeper_service_enabled: 'yes' | |||
# current state: started, stopped | |||
zookeeper_service_state: started | |||
# Files & Paths | |||
zookeeper_data_dir: /usr/local/zookeeper | |||
zookeeper_log_dir: /var/log/zookeeper | |||
zookeeper_install_path: /opt/zookeeper | |||
zookeeper_conf_dir: "{{ zookeeper_install_path }}/conf" | |||
# Connection properties | |||
# Deprecated | |||
client_port: 2181 | |||
# Deprecated | |||
init_limit: 5 | |||
# Deprecated | |||
sync_limit: 2 | |||
# Deprecated | |||
tick_time: 2000 | |||
zookeeper_client_port: "{{ client_port }}" | |||
zookeeper_init_limit: "{{ init_limit }}" | |||
zookeeper_sync_limit: "{{ sync_limit }}" | |||
zookeeper_tick_time: "{{ tick_time }}" | |||
zookeeper_autopurge_purgeInterval: 0 | |||
zookeeper_autopurge_snapRetainCount: 10 | |||
# Java options | |||
zookeeper_jmx_enabled: true | |||
zookeeper_jmx_port: 1099 | |||
zookeeper_java_opts: "-Djava.net.preferIPv4Stack=true" | |||
# Rolling file appender setttings | |||
zookeeper_rolling_log_file_max_size: 10MB | |||
zookeeper_max_rolling_log_file_count: 10 | |||
# List of dict (i.e. {zookeeper_hosts:[{host:,id:},{host:,id:},...]}) | |||
zookeeper_hosts: | |||
- host: "{{inventory_hostname}}" | |||
id: 1 | |||
# Dict of ENV settings to be written into the (optional) conf/zookeeper-env.sh | |||
zookeeper_env: {} | |||
# Controls Zookeeper myid generation | |||
zookeeper_force_myid: true | |||
zookeeper_force_reinstall: false |
@ -0,0 +1,7 @@ | |||
--- | |||
- name: Restart zookeeper | |||
systemd: | |||
name: zookeeper | |||
state: restarted | |||
when: zookeeper_service_state != 'stopped' |
@ -0,0 +1 @@ | |||
{install_date: 'Thu Dec 20 16:14:39 2018', version: 1.3.0} |
@ -0,0 +1,13 @@ | |||
--- | |||
galaxy_info: | |||
company: Idealista S.A.U. | |||
description: Apache ZooKeeper role | |||
min_ansible_version: 2.5.3.0 | |||
license: Apache 2.0 | |||
platforms: | |||
- name: Debian | |||
versions: | |||
- all | |||
categories: | |||
- configuration | |||
- distributed |
@ -0,0 +1,13 @@ | |||
# Molecule managed | |||
{% if item.registry is defined %} | |||
FROM {{ item.registry.url }}/{{ item.image }} | |||
{% else %} | |||
FROM {{ item.image }} | |||
{% endif %} | |||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ | |||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ | |||
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ | |||
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ | |||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi |
@ -0,0 +1,16 @@ | |||
******* | |||
Install | |||
******* | |||
Requirements | |||
============ | |||
* Docker Engine | |||
* docker-py | |||
Install | |||
======= | |||
.. code-block:: bash | |||
$ sudo pip install docker-py |
@ -0,0 +1,69 @@ | |||
--- | |||
- name: Create | |||
hosts: localhost | |||
connection: local | |||
gather_facts: false | |||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" | |||
vars: | |||
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" | |||
molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" | |||
molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}" | |||
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" | |||
tasks: | |||
- name: Create Dockerfiles from image names | |||
template: | |||
src: "{{ molecule_scenario_directory }}/Dockerfile.j2" | |||
dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}" | |||
with_items: "{{ molecule_yml.platforms }}" | |||
register: platforms | |||
- name: Discover local Docker images | |||
docker_image_facts: | |||
name: "molecule_local/{{ item.item.name }}" | |||
with_items: "{{ platforms.results }}" | |||
register: docker_images | |||
- name: Build an Ansible compatible image | |||
docker_image: | |||
path: "{{ molecule_ephemeral_directory }}" | |||
name: "molecule_local/{{ item.item.image }}" | |||
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}" | |||
force: "{{ item.item.force | default(true) }}" | |||
with_items: "{{ platforms.results }}" | |||
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0 | |||
- name: Create docker network(s) | |||
docker_network: | |||
name: "{{ item }}" | |||
state: present | |||
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}" | |||
- name: Create molecule instance(s) | |||
docker_container: | |||
name: "{{ item.name }}" | |||
hostname: "{{ item.name }}" | |||
image: "molecule_local/{{ item.image }}" | |||
state: started | |||
recreate: false | |||
log_driver: json-file | |||
command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" | |||
privileged: "{{ item.privileged | default(omit) }}" | |||
volumes: "{{ item.volumes | default(omit) }}" | |||
capabilities: "{{ item.capabilities | default(omit) }}" | |||
exposed_ports: "{{ item.exposed_ports | default(omit) }}" | |||
published_ports: "{{ item.published_ports | default(omit) }}" | |||
ulimits: "{{ item.ulimits | default(omit) }}" | |||
networks: "{{ item.networks | default(omit) }}" | |||
dns_servers: "{{ item.dns_servers | default(omit) }}" | |||
register: server | |||
with_items: "{{ molecule_yml.platforms }}" | |||
async: 7200 | |||
poll: 0 | |||
- name: Wait for instance(s) creation to complete | |||
async_status: | |||
jid: "{{ item.ansible_job_id }}" | |||
register: docker_jobs | |||
until: docker_jobs.finished | |||
retries: 300 | |||
with_items: "{{ server.results }}" |
@ -0,0 +1,33 @@ | |||
--- | |||
- name: Destroy | |||
hosts: localhost | |||
connection: local | |||
gather_facts: false | |||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" | |||
vars: | |||
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" | |||
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" | |||
tasks: | |||
- name: Destroy molecule instance(s) | |||
docker_container: | |||
name: "{{ item.name }}" | |||
state: absent | |||
force_kill: "{{ item.force_kill | default(true) }}" | |||
register: server | |||
with_items: "{{ molecule_yml.platforms }}" | |||
async: 7200 | |||
poll: 0 | |||
- name: Wait for instance(s) deletion to complete | |||
async_status: | |||
jid: "{{ item.ansible_job_id }}" | |||
register: docker_jobs | |||
until: docker_jobs.finished | |||
retries: 300 | |||
with_items: "{{ server.results }}" | |||
- name: Delete docker network(s) | |||
docker_network: | |||
name: "{{ item }}" | |||
state: absent | |||
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}" |
@ -0,0 +1,14 @@ | |||
--- | |||
zookeeper_version: 3.4.13 | |||
zookeeper_hosts: | |||
- host: zookeeper1 | |||
ip: "{{ (ansible_hostname == 'zookeeper1') | ternary('0.0.0.0', 'zookeeper1') }}" | |||
id: 1 | |||
- host: zookeeper2 | |||
ip: "{{ (ansible_hostname == 'zookeeper2') | ternary('0.0.0.0', 'zookeeper2') }}" | |||
id: 2 | |||
- host: zookeeper3 | |||
ip: "{{ (ansible_hostname == 'zookeeper3') | ternary('0.0.0.0', 'zookeeper3') }}" | |||
id: 3 |
@ -0,0 +1,72 @@ | |||
--- | |||
dependency: | |||
name: galaxy | |||
driver: | |||
name: docker | |||
lint: | |||
name: yamllint | |||
options: | |||
config-file: .yamllint | |||
platforms: | |||
- name: zookeeper1 | |||
groups: | |||
- zookeeper | |||
image: idealista/java-debian-ansible | |||
image_version: 3.1.1-debian9 | |||
privileged: true | |||
capabilities: | |||
- SYS_ADMIN | |||
volumes: | |||
- '/sys/fs/cgroup:/sys/fs/cgroup:ro' | |||
networks: | |||
- name: zookeeper-network | |||
links: | |||
- zookeeper2:zookeeper2 | |||
- zookeeper3:zookeeper3 | |||
command: '/lib/systemd/systemd' | |||
- name: zookeeper2 | |||
groups: | |||
- zookeeper | |||
image: idealista/java-debian-ansible | |||
image_version: 3.1.1-debian9 | |||
privileged: true | |||
capabilities: | |||
- SYS_ADMIN | |||
volumes: | |||
- '/sys/fs/cgroup:/sys/fs/cgroup:ro' | |||
networks: | |||
- name: zookeeper-network | |||
links: | |||
- zookeeper1:zookeeper1 | |||
- zookeeper3:zookeeper3 | |||
command: '/lib/systemd/systemd' | |||
- name: zookeeper3 | |||
groups: | |||
- zookeeper | |||
image: idealista/java-debian-ansible | |||
image_version: 3.1.1-debian9 | |||
privileged: true | |||
capabilities: | |||
- SYS_ADMIN | |||
volumes: | |||
- '/sys/fs/cgroup:/sys/fs/cgroup:ro' | |||
networks: | |||
- name: zookeeper-network | |||
links: | |||
- zookeeper1:zookeeper1 | |||
- zookeeper2:zookeeper2 | |||
command: '/lib/systemd/systemd' | |||
provisioner: | |||
name: ansible | |||
lint: | |||
name: ansible-lint | |||
scenario: | |||
name: default | |||
verifier: | |||
name: goss | |||
lint: | |||
name: yamllint |
@ -0,0 +1,14 @@ | |||
--- | |||
- name: Converge | |||
hosts: zookeeper | |||
pre_tasks: | |||
- name: installing required libs | |||
apt: | |||
pkg: "{{ item }}" | |||
state: present | |||
with_items: | |||
- net-tools | |||
- netcat | |||
roles: | |||
- zookeeper-role |
@ -0,0 +1,5 @@ | |||
--- | |||
- name: Prepare | |||
hosts: all | |||
gather_facts: false | |||
tasks: [] |
@ -0,0 +1,52 @@ | |||
group: | |||
{{ zookeeper_group }}: | |||
exists: true | |||
user: | |||
{{ zookeeper_user }}: | |||
exists: true | |||
groups: | |||
- {{ zookeeper_group }} | |||
file: | |||
{{ zookeeper_data_dir }}/myid: | |||
exists: true | |||
owner: {{ zookeeper_user }} | |||
group: {{ zookeeper_group }} | |||
filetype: file | |||
{{ zookeeper_conf_dir }}/zoo.cfg: | |||
exists: true | |||
owner: {{ zookeeper_user }} | |||
group: {{ zookeeper_group }} | |||
filetype: file | |||
{{ zookeeper_conf_dir }}/zookeeper-env.sh: | |||
exists: true | |||
owner: {{ zookeeper_user }} | |||
group: {{ zookeeper_group }} | |||
filetype: file | |||
{{ zookeeper_conf_dir }}/log4j.properties: | |||
exists: true | |||
owner: {{ zookeeper_user }} | |||
group: {{ zookeeper_group }} | |||
filetype: file | |||
service: | |||
zookeeper: | |||
enabled: true | |||
running: true | |||
process: | |||
java: | |||
running: true | |||
command: | |||
bash /opt/zookeeper/bin/zkServer.sh status: | |||
# required attributes | |||
exit-status: 0 | |||
timeout: 10000 | |||
stdout: | |||
- "/Mode: (follower|leader)/" | |||
port: | |||
tcp:{{ zookeeper_client_port }}: | |||
listening: true |
@ -0,0 +1,60 @@ | |||
--- | |||
# This is an example playbook to execute goss tests. | |||
# Tests need distributed to the appropriate ansible host/groups | |||
# prior to execution by `goss validate`. | |||
# | |||
# The goss ansible module is installed with molecule. The ANSIBLE_LIBRARY | |||
# path is updated appropriately on `molecule verify`. | |||
# Details about ansible module: | |||
# - https://github.com/indusbox/goss-ansible | |||
- name: Verify | |||
hosts: all | |||
vars: | |||
goss_version: v0.3.6 | |||
goss_arch: amd64 | |||
goss_dst: /usr/local/bin/goss | |||
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}" | |||
goss_test_directory: /tmp | |||
goss_format: documentation | |||
vars_files: | |||
- ../../defaults/main.yml | |||
- ../../vars/main.yml | |||
- ./group_vars/zookeeper.yml | |||
tasks: | |||
- name: Download and install goss | |||
get_url: | |||
url: "{{ goss_url }}" | |||
dest: "{{ goss_dst }}" | |||
mode: 0755 | |||
- name: Copy tests to remote | |||
template: | |||
src: "{{ item }}" | |||
dest: "{{ goss_test_directory }}/{{ item | basename }}" | |||
with_fileglob: | |||
- "{{ playbook_dir }}/tests/test_*.yml" | |||
- name: Register test files | |||
shell: "ls {{ goss_test_directory }}/test_*.yml" | |||
register: test_files | |||
- name: Execute Goss tests | |||
command: "goss -g {{ item }} validate --format {{ goss_format }}" | |||
register: test_results | |||
with_items: "{{ test_files.stdout_lines }}" | |||
ignore_errors: true | |||
- name: Display details about the goss results | |||
debug: | |||
msg: "{{ item.stdout_lines }}" | |||
with_items: "{{ test_results.results }}" | |||
- name: Fail when tests fail | |||
fail: | |||
msg: "Goss failed to validate" | |||
when: item.rc != 0 | |||
with_items: "{{ test_results.results }}" |
@ -0,0 +1,38 @@ | |||
--- | |||
- name: ZOOKEEPER | Overwrite myid file. | |||
template: | |||
src: myid.j2 | |||
dest: "{{ zookeeper_data_dir }}/myid" | |||
force: "{{ zookeeper_force_myid }}" | |||
owner: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
notify: | |||
- Restart zookeeper | |||
- name: ZOOKEEPER | Overwrite default config file | |||
template: | |||
src: zoo.cfg.j2 | |||
dest: "{{ zookeeper_conf_dir }}/zoo.cfg" | |||
owner: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
notify: | |||
- Restart zookeeper | |||
- name: ZOOKEEPER | Configure zookeeper-env.sh | |||
template: | |||
src: zookeeper-env.sh.j2 | |||
dest: "{{ zookeeper_conf_dir }}/zookeeper-env.sh" | |||
owner: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
notify: | |||
- Restart zookeeper | |||
- name: ZOOKEEPER | Update the log4j | |||
template: | |||
src: log4j.properties.j2 | |||
dest: "{{ zookeeper_conf_dir }}/log4j.properties" | |||
owner: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
notify: | |||
- Restart zookeeper |
@ -0,0 +1,65 @@ | |||
--- | |||
- name: ZOOKEEPER | Removing dependencies | |||
apt: | |||
pkg: "zookeeper" | |||
state: absent | |||
- name: ZOOKEEPER | Installing dependencies | |||
apt: | |||
pkg: "{{ item }}" | |||
state: present | |||
with_items: "{{ zookeeper_required_libs }}" | |||
tags: | |||
skip_ansible_lint | |||
- name: ZOOKEEPER | Ensure ZooKeeper group | |||
group: | |||
name: "{{ zookeeper_group }}" | |||
- name: ZOOKEEPER | Ensure ZooKeeper user | |||
user: | |||
name: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
home: /bin/false | |||
ignore_errors: true | |||
- name: ZOOKEEPER | Create install path | |||
file: | |||
path: "{{ item }}" | |||
state: directory | |||
owner: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
with_items: | |||
- "{{ zookeeper_install_path }}" | |||
- "{{ zookeeper_conf_dir }}" | |||
- "{{ zookeeper_data_dir }}" | |||
- "{{ zookeeper_log_dir }}" | |||
- name: ZOOKEEPER | Check ZooKeeper version | |||
shell: echo status | nc localhost 2181 | |||
register: zookeeper_check | |||
changed_when: false | |||
failed_when: false | |||
- name: ZOOKEEPER | Untar ZooKeeper | |||
unarchive: | |||
extra_opts: ['--strip-components=1'] | |||
src: "{{ zookeeper_url }}" | |||
remote_src: true | |||
dest: "{{ zookeeper_install_path }}" | |||
owner: "{{ zookeeper_user }}" | |||
group: "{{ zookeeper_group }}" | |||
when: "zookeeper_force_reinstall or zookeeper_check is failed or zookeeper_version not in zookeeper_check.stdout" | |||
- name: ZOOKEEPER | Create systemd service | |||
template: | |||
src: zookeeper.service.j2 | |||
dest: /etc/systemd/system/zookeeper.service | |||
notify: | |||
- Restart zookeeper | |||
- name: ZOOKEEPER | Remove upstart service | |||
file: | |||
path: /etc/init.d/zookeeper | |||
state: absent |
@ -0,0 +1,16 @@ | |||
--- | |||
- name: ZOOKEEPER | Install | |||
import_tasks: install.yml | |||
tags: | |||
- install | |||
- name: ZOOKEEPER | Config | |||
import_tasks: config.yml | |||
tags: | |||
- config | |||
- name: ZOOKEEPER | Service | |||
import_tasks: service.yml | |||
tags: | |||
- service |
@ -0,0 +1,8 @@ | |||
--- | |||
- name: ZOOKEEPER | Configuring ZooKeeper service | |||
systemd: | |||
name: zookeeper | |||
state: "{{ zookeeper_service_state }}" | |||
enabled: "{{ zookeeper_service_enabled }}" | |||
daemon_reload: true |
@ -0,0 +1,59 @@ | |||
# {{ansible_managed}} | |||
# Define some default values that can be overridden by system properties | |||
zookeeper.root.logger=INFO, ROLLINGFILE | |||
zookeeper.console.threshold=INFO | |||
zookeeper.log.dir={{ zookeeper_log_dir }} | |||
zookeeper.log.file=zookeeper.log | |||
zookeeper.log.threshold=INFO | |||
zookeeper.tracelog.dir={{ zookeeper_log_dir }} | |||
zookeeper.tracelog.file=zookeeper_trace.log | |||
# | |||
# ZooKeeper Logging Configuration | |||
# | |||
# Format is "<default threshold> (, <appender>)+ | |||
# DEFAULT: console appender only | |||
log4j.rootLogger=${zookeeper.root.logger} | |||
# Example with rolling log file | |||
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE | |||
# Example with rolling log file and tracing | |||
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE | |||
# | |||
# Log INFO level and above messages to the console | |||
# | |||
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender | |||
log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold} | |||
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout | |||
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n | |||
# | |||
# Add ROLLINGFILE to rootLogger to get log file output | |||
# Log DEBUG level and above messages to a log file | |||
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender | |||
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold} | |||
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file} | |||
# Max log file size of 10MB | |||
log4j.appender.ROLLINGFILE.MaxFileSize={{ zookeeper_rolling_log_file_max_size }} | |||
# uncomment the next line to limit number of backup files | |||
#log4j.appender.ROLLINGFILE.MaxBackupIndex={{ zookeeper_max_rolling_log_file_count }} | |||
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout | |||
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n | |||
# | |||
# Add TRACEFILE to rootLogger to get log file output | |||
# Log DEBUG level and above messages to a log file | |||
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender | |||
log4j.appender.TRACEFILE.Threshold=TRACE | |||
log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file} | |||
log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout | |||
### Notice we are including log4j's NDC here (%x) | |||
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n |
@ -0,0 +1,11 @@ | |||
{% for server in zookeeper_hosts %} | |||
{% if server.host is defined %} | |||
{% if server.host == inventory_hostname %} | |||
{{ server.id }} | |||
{% endif %} | |||
{% else %} | |||
{% if server == inventory_hostname %} | |||
{{ loop.index }} | |||
{% endif %} | |||
{% endif %} | |||
{% endfor %} |
@ -0,0 +1,23 @@ | |||
tickTime={{ zookeeper_tick_time }} | |||
dataDir={{ zookeeper_data_dir }} | |||
dataLogDir={{ zookeeper_log_dir }} | |||
clientPort={{ zookeeper_client_port }} | |||
initLimit={{ zookeeper_init_limit }} | |||
syncLimit={{ zookeeper_sync_limit }} | |||
{% if zookeeper_autopurge_purgeInterval > 0 %} | |||
autopurge.purgeInterval={{ zookeeper_autopurge_purgeInterval }} | |||
autopurge.snapRetainCount={{ zookeeper_autopurge_snapRetainCount }} | |||
{% endif %} | |||
{% for server in zookeeper_hosts %} | |||
{% if server.host is defined %} | |||
{% if server.ip is defined %} | |||
server.{{server.id}}={{server.ip}}:2888:3888 | |||
{% else %} | |||
server.{{server.id}}={{server.host}}:2888:3888 | |||
{% endif %} | |||
{% else %} | |||
server.{{loop.index}}={{server}}:2888:3888 | |||
{% endif %} | |||
{% endfor %} |
@ -0,0 +1,5 @@ | |||
{% if zookeeper_env is defined %} | |||
{% for key, value in zookeeper_env.items() | sort %} | |||
{{key}}={{value}} | |||
{% endfor %} | |||
{% endif %} |
@ -0,0 +1,20 @@ | |||
# {{ansible_managed}} | |||
[Unit] | |||
Description=ZooKeeper | |||
After=network.target | |||
Wants=network.target | |||
[Service] | |||
Type=simple | |||
User={{ zookeeper_user }} | |||
Group={{zookeeper_group }} | |||
Environment='ZOO_LOG_DIR={{ zookeeper_log_dir }}' | |||
Environment='ZOO_LOG4J_PROP=INFO,ROLLINGFILE' | |||
ExecStart={{zookeeper_install_path}}/bin/zkServer.sh start-foreground | |||
Restart=on-failure | |||