-
Notifications
You must be signed in to change notification settings - Fork 51
Ansible playbooks to manage Redpanda Connect #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bfbarkhouse-redpanda
wants to merge
22
commits into
redpanda-data:main
Choose a base branch
from
bfbarkhouse-redpanda:rpcn-automation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1fbbecb
Create redpanda.license
bfbarkhouse-redpanda f366369
Create pipeline.yaml
bfbarkhouse-redpanda b220f4f
Create rpcn.service
bfbarkhouse-redpanda c3adb23
Create rpcn-ent.service
bfbarkhouse-redpanda 96b5f26
Create stage-rpcn-ent.yml
bfbarkhouse-redpanda 0e9c003
Create stage-rpcn.yml
bfbarkhouse-redpanda f98a4f2
Create stop-pipeline-ent.yml
bfbarkhouse-redpanda cab118a
Create stop-pipleline.yml
bfbarkhouse-redpanda 47aa40d
Create update-pipeline-ent.yml
bfbarkhouse-redpanda 969df81
Create update-pipeline.yml
bfbarkhouse-redpanda de5d340
Delete ansible/rpcn_files/rpcn-ent.service
bfbarkhouse-redpanda 1171552
Update rpcn.service
bfbarkhouse-redpanda 9bc7864
Delete ansible/stage-rpcn-ent.yml
bfbarkhouse-redpanda 1f0e477
Delete ansible/stop-pipeline-ent.yml
bfbarkhouse-redpanda 19190a4
Delete ansible/update-pipeline-ent.yml
bfbarkhouse-redpanda 6d893b5
Update stage-rpcn.yml
bfbarkhouse-redpanda 47534cb
Update stop-pipleline.yml
bfbarkhouse-redpanda bb2589d
Update update-pipeline.yml
bfbarkhouse-redpanda bc61837
Update stage-rpcn.yml
bfbarkhouse-redpanda 37a7988
Update stage-rpcn.yml
bfbarkhouse-redpanda 90d07d1
Update stop-pipleline.yml
bfbarkhouse-redpanda 81cd941
Update update-pipeline.yml
bfbarkhouse-redpanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,12 @@ | ||
| #Example pipeline to smoke test with | ||
| input: | ||
| label: "file_input" | ||
| file: | ||
| paths: [ "/opt/rpcn/pipeline.yaml" ] | ||
| scanner: | ||
| lines: {} | ||
|
|
||
| output: | ||
| label: "stdout" | ||
| stdout: | ||
| codec: lines | ||
This file contains hidden or 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 @@ | ||
| #Paste license key here | ||
This file contains hidden or 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,13 @@ | ||
| [Unit] | ||
| Description=Redpanda Connect Pipeline | ||
| After=network.target | ||
|
|
||
| [Service] | ||
| ExecStart=/etc/redpanda/rpk connect run /etc/redpanda/pipeline.yaml | ||
| Restart=on-failure | ||
| User=ubuntu | ||
| #Group=redpanda-connect | ||
| Environment="REDPANDA_PIPELINE_ID=%H" | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
This file contains hidden or 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,93 @@ | ||
| - name: Install redpanda-connect and set up systemd service | ||
| hosts: connect | ||
| become: true | ||
|
|
||
| vars: | ||
| rpcn_dir: /etc/redpanda | ||
| local_files_dir: "./rpcn_files" # directory on your control machine to upload | ||
|
|
||
| pre_tasks: | ||
| - name: Set package script location for Debian/Ubuntu | ||
| set_fact: | ||
| download_url: "https://dl.redpanda.com/nzc4ZYQK3WRGd9sy/redpanda/cfg/setup/bash.deb.sh" | ||
| when: ansible_facts['os_family'] == "Debian" | ||
|
|
||
| - name: Set package script location for RHEL-family | ||
| set_fact: | ||
| download_url: "https://dl.redpanda.com/nzc4ZYQK3WRGd9sy/redpanda/cfg/setup/bash.rpm.sh" | ||
| when: ansible_facts['os_family'] == "RedHat" | ||
|
|
||
|
|
||
| tasks: | ||
| # --- Ensure target directory exists before unarchive --- | ||
| - name: Ensure /etc exists | ||
| file: | ||
| path: /etc | ||
| state: directory | ||
| mode: "0755" | ||
|
|
||
| - name: Ensure target directory exists | ||
| file: | ||
| path: "{{ rpcn_dir }}" | ||
| state: directory | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
|
|
||
| - name: Verify target directory exists | ||
| stat: | ||
| path: "{{ rpcn_dir }}" | ||
| register: rpcn_dir_stat | ||
|
|
||
| - name: Fail if target directory is missing | ||
| fail: | ||
| msg: "Target directory {{ rpcn_dir }} was not created" | ||
| when: not rpcn_dir_stat.stat.exists | ||
|
|
||
| # --- Install redpanda-connect package --- | ||
| - name: dnf install redpanda-connect | ||
| ansible.builtin.dnf: | ||
| name: redpanda-connect | ||
| state: present | ||
| when: ansible_facts['os_family'] == "RedHat" | ||
|
|
||
| - name: apt install redpanda-connect | ||
| ansible.builtin.apt: | ||
| name: redpanda-connect | ||
| state: present | ||
| update_cache: yes | ||
| when: ansible_facts['os_family'] == "Debian" | ||
|
|
||
| # --- Copy your local files to the REMOTE host(s) --- | ||
| - name: Copy your local files into /etc/redpanda (recursive) | ||
| copy: | ||
| src: "{{ local_files_dir }}/" | ||
| dest: "{{ rpcn_dir }}/" | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
|
|
||
| # --- Install systemd unit --- | ||
| - name: Copy service file from /etc/redpanda to systemd unit dir | ||
| copy: | ||
| src: "{{ rpcn_dir }}/rpcn.service" | ||
| dest: /etc/systemd/system/rpcn.service | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
| remote_src: true | ||
| notify: daemon-reload | ||
|
|
||
| - name: Enable and start rpcn service | ||
| systemd: | ||
| name: rpcn.service | ||
| enabled: true | ||
| state: started | ||
|
|
||
| handlers: | ||
| - name: daemon-reload | ||
| systemd: | ||
| daemon_reload: true | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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,14 @@ | ||
| - name: Stop rpcn service (skip if unit missing) | ||
| hosts: connect | ||
| become: true | ||
| tasks: | ||
| - name: Check if rpcn unit file exists | ||
| stat: | ||
| path: /etc/systemd/system/rpcn.service | ||
| register: rpcn_unit | ||
|
|
||
| - name: Stop rpcn.service when present | ||
| systemd: | ||
| name: rpcn.service | ||
| state: stopped | ||
| when: rpcn_unit.stat.exists |
This file contains hidden or 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,37 @@ | ||
| - name: Update rpcn pipeline and restart service | ||
| hosts: connect | ||
| become: true | ||
|
|
||
| vars: | ||
| rpcn_dir: /etc/redpanda | ||
| local_files_dir: "./rpcn_files" # same convention as your other playbook | ||
|
|
||
| tasks: | ||
| - name: Ensure target directory exists | ||
| file: | ||
| path: "{{ rpcn_dir }}" | ||
| state: directory | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
|
|
||
| - name: Copy pipeline.yaml to /etc/redpanda | ||
| copy: | ||
| src: "{{ local_files_dir }}/pipeline.yaml" | ||
| dest: "{{ rpcn_dir }}/pipeline.yaml" | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
| notify: | ||
| - daemon-reload | ||
| - restart rpcn | ||
|
|
||
| handlers: | ||
| - name: daemon-reload | ||
| systemd: | ||
| daemon_reload: true | ||
|
|
||
| - name: restart rpcn | ||
| systemd: | ||
| name: rpcn.service | ||
| state: restarted |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should follow the same license install pattern that's used in redpanda-ansible-collection