diff --git a/ansible/rpcn_files/pipeline.yaml b/ansible/rpcn_files/pipeline.yaml new file mode 100644 index 0000000..44b69b4 --- /dev/null +++ b/ansible/rpcn_files/pipeline.yaml @@ -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 diff --git a/ansible/rpcn_files/redpanda.license b/ansible/rpcn_files/redpanda.license new file mode 100644 index 0000000..a026809 --- /dev/null +++ b/ansible/rpcn_files/redpanda.license @@ -0,0 +1 @@ +#Paste license key here diff --git a/ansible/rpcn_files/rpcn.service b/ansible/rpcn_files/rpcn.service new file mode 100644 index 0000000..a5ac84b --- /dev/null +++ b/ansible/rpcn_files/rpcn.service @@ -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 diff --git a/ansible/stage-rpcn.yml b/ansible/stage-rpcn.yml new file mode 100644 index 0000000..3a842f4 --- /dev/null +++ b/ansible/stage-rpcn.yml @@ -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 + + + diff --git a/ansible/stop-pipleline.yml b/ansible/stop-pipleline.yml new file mode 100644 index 0000000..3e7bbd5 --- /dev/null +++ b/ansible/stop-pipleline.yml @@ -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 diff --git a/ansible/update-pipeline.yml b/ansible/update-pipeline.yml new file mode 100644 index 0000000..614af91 --- /dev/null +++ b/ansible/update-pipeline.yml @@ -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