diff --git a/ansible/deploy-fastpath.yml b/ansible/deploy-fastpath.yml new file mode 100644 index 00000000..eadd362a --- /dev/null +++ b/ansible/deploy-fastpath.yml @@ -0,0 +1,6 @@ +--- +- import_playbook: ansible-version.yml + +- hosts: fastpath.ooni.nu + roles: + - role: fastpath diff --git a/ansible/roles/fastpath/tasks/main.yml b/ansible/roles/fastpath/tasks/main.yml new file mode 100644 index 00000000..edf6aeb3 --- /dev/null +++ b/ansible/roles/fastpath/tasks/main.yml @@ -0,0 +1,44 @@ +--- + +# Deploy the fastpath +# +# Deploy .deb package to the fastpath host +# +# Fetch SSH pubkey and deploy it on the collector hosts +# +# Set the hostname of the collectors in the fastpath config file + +# Usage: place the .deb file in files/ +# update the version number as needed + +#- name: pull fastpath .deb package +# copy: +# src: files/fastpath_0.1_all.deb +# dest: /root/ +# owner: root +# group: root +# mode: '0644' + +#- name: install .deb using dpkg +# apt: +# deb: '{{ item }}' +# state: present +# with_items: +# - /root/fastpath_0.1_all.deb + +- name: generate fastpath.conf file with active collectors names in it + template: + owner: "root" + group: "root" + mode: '0644' + src: "fastpath.conf.j2" + dest: "/etc/fastpath.conf" + +- name: fill active collectors SSH pubkeys into fastpath's known_hosts + template: + owner: "fastpath" + group: "fastpath" + mode: '0644' + src: "known_collectors" + dest: /var/lib/fastpath/ssh/known_hosts + diff --git a/ansible/roles/fastpath/templates/fastpath.conf.j2 b/ansible/roles/fastpath/templates/fastpath.conf.j2 new file mode 100644 index 00000000..dc06bb67 --- /dev/null +++ b/ansible/roles/fastpath/templates/fastpath.conf.j2 @@ -0,0 +1,7 @@ +# Deployed by https://github.com/ooni/sysadmin/blob/master/ansible/roles/fastpath +# deploy-fastpath.yml +# roles/fastpath/tasks/main.yml +# roles/fastpath/templates/fastpath.conf.j2 + +[DEFAULT] +collectors = {{ groups['active_collector'] | join(' ') }} diff --git a/ansible/roles/fastpath/templates/known_collectors b/ansible/roles/fastpath/templates/known_collectors new file mode 100644 index 00000000..2f5b326e --- /dev/null +++ b/ansible/roles/fastpath/templates/known_collectors @@ -0,0 +1,4 @@ +# Deployed by https://github.com/ooni/sysadmin/blob/master/ansible/roles/fastpath/templates/known_collectors +{% for host in groups.active_collector %} +{{ lookup('pipe', 'grep -F -e {}, {}/../ext/known_hosts'.format(host, inventory_dir)) }} +{% endfor %} diff --git a/ansible/roles/ooni-collector/defaults/main.yml b/ansible/roles/ooni-collector/defaults/main.yml index 7dd37401..08a07307 100644 --- a/ansible/roles/ooni-collector/defaults/main.yml +++ b/ansible/roles/ooni-collector/defaults/main.yml @@ -7,5 +7,5 @@ collector_tag: '20190221-0980b82a' collector_data_dir: '{{ CHANGE_ME }}' # it varies across collectors collector_domain: '{{ CHANGE_ME }}' with_nginx: yes -sshfeeder_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID3MZP0tYUzaZOZa8JhRIx3PiTXwXfwQdTPa/RwDmwcA" +sshfeeder_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHAxyZVlDHc50fim5qWkf+yQhVpVR6d4btNBE8xb4XCd fastpath" ... diff --git a/ansible/roles/ooni-collector/tasks/main.yml b/ansible/roles/ooni-collector/tasks/main.yml index e750cd5a..3dfeef67 100644 --- a/ansible/roles/ooni-collector/tasks/main.yml +++ b/ansible/roles/ooni-collector/tasks/main.yml @@ -144,14 +144,18 @@ - name: Setup the sshfeeder account user: name: sshfeeder + group: sshfeeder + groups: "{{ collector_user }}" createhome: yes append: yes shell: /bin/bash home: "/home/sshfeeder" system: no + tags: collector_ssh - name: Set authorized key for sshfeeder authorized_key: user: sshfeeder state: present key: "{{ sshfeeder_key }}" + tags: collector_ssh