diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..79ce9a0 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,13 @@ +- job: + name: ffrouting-deploy + parent: base + run: tests/test.yml + nodeset: debian-buster + +- project: + check: + jobs: + - ffrouting-deploy + gate: + jobs: + - ffrouting-deploy diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..5f284b0 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,14 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..820a248 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,22 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. + +- name: Restart frr + become: true + become_user: root + service: + name: frr + state: restarted + enabled: yes diff --git a/tasks/frr_install.yml b/tasks/frr_install.yml new file mode 100644 index 0000000..b0d57d3 --- /dev/null +++ b/tasks/frr_install.yml @@ -0,0 +1,31 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. + +- name: Install frr + become: true + become_user: root + block: + - name: Apply package management distro specific configuration + include_tasks: "frr_install_{{ ansible_pkg_mgr | lower }}.yml" + + - name: Install required distro packages + package: + name: "{{ frr_distro_packages }}" + state: present + register: install_packages + until: install_packages is success + retries: 5 + delay: 2 + notify: Restart frr diff --git a/tasks/frr_install_apt.yml b/tasks/frr_install_apt.yml new file mode 100644 index 0000000..4575403 --- /dev/null +++ b/tasks/frr_install_apt.yml @@ -0,0 +1,60 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. + +- name: Install gpg tooling for key management + apt: + name: gnupg + state: present + register: _install_gpg + until: _install_gpg is success + retries: 5 + delay: 2 + +- name: Add/Remove repositories gpg keys + apt_key: + id: "{{ key.id | default(omit) }}" + data: "{{ key.data | default(omit) }}" + keyserver: "{{ key.keyserver | default(omit) }}" + url: "{{ key.url | default(omit) }}" + state: "{{ key.state | default('present') }}" + with_items: "{{ frr_repos_keys }}" + loop_control: + loop_var: key + register: _add_apt_keys + until: _add_apt_keys is success + retries: 5 + delay: 2 + +- name: Add/remove defined APT repositories + apt_repository: + repo: "{{ repo.repo }}" + state: "{{ repo.state | default('present') }}" + filename: "{{ repo.filename | default(omit) }}" + update_cache: no + with_items: "{{ frr_repos }}" + loop_control: + loop_var: repo + register: _adding_apt_repo + +- name: Update Apt cache + apt: + update_cache: yes + when: + - _adding_apt_repo is changed + register: _update_apt_cache + until: _update_apt_cache is success + changed_when: false + retries: 5 + delay: 2 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..7eab38a --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,20 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. + +- name: Gather variables for each operating system + include_vars: "{{ ansible_os_family | lower }}.yml" + +- name: Install frr + include_tasks: frr_install.yml diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..001b666 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. + +- name: Installing frr + hosts: all + roles: + - frrouting + + post_tasks: + - name: wait after service restart + pause: + seconds: 30 + + - name: Check service state + service_facts: + + - name: Fail if frr is down + fail: + msg: frr is not up + when: ansible_facts.services['frr'].state != 'running' diff --git a/vars/debian.yml b/vars/debian.yml new file mode 100644 index 0000000..e913c08 --- /dev/null +++ b/vars/debian.yml @@ -0,0 +1,34 @@ +--- +# Copyright 2020, VEXXHOST, Inc. +# +# 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. + +frr_repos_keys: + - id: 4A56C7738BB3F81595A805D2A832769908F13ED1 + url: "https://deb.frrouting.org/frr/keys.asc" + state: present + - id: 3D9968AC9AE7BE1169288DDB1FD5839895F57FDA + url: "https://deb.frrouting.org/frr/keys.asc" + state: present + - id: A90FC36D9429409798E9C2D874DEED43AB194DBF + url: "https://deb.frrouting.org/frr/keys.asc" + state: present + +frr_repos: + - repo: "deb {{ apt_repo_url | default('https://deb.frrouting.org/frr ' ~ ansible_distribution_release ~ ' frr-stable') }}" + state: present + filename: "frr" + +frr_distro_packages: + - frr + - frr-pythontools