-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for configuration of arbitrary node and cluster configuration items. N.B. Further work to be done on idempotence and integration of TLS. #74 and #86 will need some rework
- Loading branch information
1 parent
8aa02b7
commit be48d76
Showing
14 changed files
with
191 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ ansible/playbooks/tls/ca | |
ansible/playbooks/tls/certs | ||
hosts.ini | ||
.DS_Store | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
|
||
redpanda_mode: production | ||
redpanda_admin_api_port: 9644 | ||
redpanda_kafka_port: 9092 | ||
redpanda_rpc_port: 33145 | ||
|
||
redpanda_key_file: /etc/redpanda/certs/node.key | ||
redpanda_cert_file: /etc/redpanda/certs/node.crt | ||
redpanda_truststore_file: /etc/redpanda/certs/truststore.pem |
27 changes: 27 additions & 0 deletions
27
ansible/playbooks/roles/redpanda_broker/tasks/install-redpanda.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- name: add the redpanda repo | ||
shell: | | ||
curl -1sLf https://packages.vectorized.io/sMIXnoa7DK12JW4A/redpanda/cfg/setup/bash.deb.sh | sudo -E bash | ||
args: | ||
warn: no | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: add the redpanda repo | ||
shell: | | ||
curl -1sLf https://packages.vectorized.io/sMIXnoa7DK12JW4A/redpanda/cfg/setup/bash.rpm.sh | sudo -E bash | ||
args: | ||
warn: no | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- name: install redpanda from repository | ||
package: | ||
name: | ||
- redpanda | ||
state: present | ||
update_cache: yes | ||
|
||
- name: set data dir file perms | ||
file: | ||
path: /var/lib/redpanda/data | ||
owner: redpanda | ||
group: redpanda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
|
||
- name: Install Redpanda | ||
include_tasks: install-redpanda.yml | ||
|
||
- name: Start Redpanda | ||
include_tasks: start-redpanda.yml |
59 changes: 59 additions & 0 deletions
59
ansible/playbooks/roles/redpanda_broker/tasks/start-redpanda.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
- name: ensure /etc/redpanda exists | ||
file: | ||
path: /etc/redpanda | ||
state: directory | ||
mode: 0755 | ||
|
||
- name: Reset configuration | ||
set_fact: | ||
configuration: {} | ||
|
||
- name: Generate configurations | ||
set_fact: | ||
configuration: "{{ configuration | combine(lookup('template', custom_config_template.template) | from_yaml, recursive=True) }}" | ||
loop: "{{ custom_config_templates }}" | ||
loop_control: | ||
loop_var: custom_config_template | ||
when: custom_config_template.condition | default(True) | ||
|
||
- name: Merge with user-provided overrides (via redpanda variable) | ||
set_fact: | ||
configuration: "{{ configuration | combine(redpanda | default({}), recursive=True) }}" | ||
|
||
- name: Generate bootstrap | ||
ansible.builtin.template: | ||
src: "bootstrap.yml" | ||
dest: "/etc/redpanda/.bootstrap.yaml" | ||
owner: redpanda | ||
group: redpanda | ||
|
||
- name: Generate Node config | ||
ansible.builtin.template: | ||
src: "redpanda.yml" | ||
dest: "/etc/redpanda/redpanda.yaml" | ||
owner: redpanda | ||
group: redpanda | ||
|
||
- name: configure redpanda | ||
shell: | | ||
set -e | ||
sudo -u redpanda rpk redpanda mode production | ||
{% if hostvars[groups['redpanda'][0]].id == hostvars[inventory_hostname].id %} | ||
sudo -u redpanda rpk redpanda config bootstrap \ | ||
--id {{ hostvars[inventory_hostname].id }} \ | ||
--self {{ hostvars[inventory_hostname].private_ip }} | ||
{% else %} | ||
sudo -u redpanda rpk redpanda config bootstrap \ | ||
--id {{ hostvars[inventory_hostname].id }} \ | ||
--self {{ hostvars[inventory_hostname].private_ip }} \ | ||
--ips {{ groups["redpanda"] | map('extract', hostvars) | map(attribute='private_ip') | join(',') }} | ||
{% endif %} | ||
- name: start redpanda-tuner | ||
systemd: | ||
name: redpanda-tuner | ||
state: started | ||
- name: start redpanda | ||
systemd: | ||
name: redpanda | ||
state: started |
1 change: 1 addition & 0 deletions
1
ansible/playbooks/roles/redpanda_broker/templates/bootstrap.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ configuration.cluster | to_nice_yaml }} |
31 changes: 31 additions & 0 deletions
31
ansible/playbooks/roles/redpanda_broker/templates/configs/defaults.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{% set address_attribute = 'inventory_hostname' if (advertise_public_ips | d() | bool) else 'private_ip' %} | ||
cluster: | ||
rpc_server_tcp_recv_buf: 65536 | ||
enable_rack_awareness: {{ true if rack is defined and rack != -1 else false }} | ||
node: | ||
cluster_id: redpanda | ||
organization: redpanda-test | ||
redpanda: | ||
node_id: "{{ id }}" | ||
data_directory: "/var/lib/redpanda/data" | ||
advertised_kafka_api: | ||
- address: {{ hostvars[inventory_hostname][address_attribute] }} | ||
port: {{ redpanda_kafka_port }} | ||
advertised_rpc_api: | ||
address: {{ hostvars[inventory_hostname].private_ip }} | ||
port: {{ redpanda_rpc_port }} | ||
rpc_server: | ||
address: {{ hostvars[inventory_hostname].private_ip }} | ||
port: {{ redpanda_rpc_port }} | ||
rack: {{ rack | default('null') }} | ||
rpk: | ||
admin_api: | ||
addresses: | ||
{% for host in groups["redpanda"] %} | ||
- {{ hostvars[host][address_attribute] }}:{{ redpanda_admin_api_port }} | ||
{% endfor %} | ||
kafka_api: | ||
brokers: | ||
{% for host in groups["redpanda"] %} | ||
- {{ hostvars[host][address_attribute] }}:{{ redpanda_kafka_port }} | ||
{% endfor %} |
27 changes: 27 additions & 0 deletions
27
ansible/playbooks/roles/redpanda_broker/templates/configs/tls.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
node: | ||
redpanda: | ||
admin_api_tls: | ||
enabled: true, | ||
require_client_auth: false, | ||
key_file: "{{ redpanda_key_file }}" | ||
cert_file: "{{ redpanda_cert_file }}" | ||
truststore_file: "{{ redpanda_truststore_file }}" | ||
kafka_api_tls: | ||
enabled: true | ||
require_client_auth: false | ||
key_file: "{{ redpanda_key_file }}" | ||
cert_file: "{{ redpanda_cert_file }}" | ||
truststore_file: "{{ redpanda_truststore_file }}" | ||
rpc_server_tls: | ||
enabled: true, | ||
require_client_auth: false, | ||
key_file: "{{ redpanda_key_file }}" | ||
cert_file: "{{ redpanda_cert_file }}" | ||
truststore_file: "{{ redpanda_truststore_file }}" | ||
rpk: | ||
admin_api: | ||
tls: | ||
truststore_file: "{{ redpanda_truststore_file }}" | ||
kafka_api: | ||
tls: | ||
truststore_file: "{{ redpanda_truststore_file }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ configuration.node | to_nice_yaml }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
custom_config_templates: | ||
- template: configs/defaults.j2 | ||
- template: configs/tls.j2 | ||
condition: "{{ tls | default(False) | bool }}" |
This file was deleted.
Oops, something went wrong.