Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions roles/nat64_appliance/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ cifmw_nat64_appliance_download_timeout: 600 # 10 minutes

cifmw_nat64_ipv6_prefix: "2620:cf:cf:fc00::/64"
cifmw_nat64_ipv6_tayga_address: "2620:cf:cf:fc00::3"

# Set to false to use standard ansible.builtin.shell instead of cifmw.general.ci_script
# This makes the role usable outside of ci-framework context
cifmw_nat64_appliance_use_ci_script: true
60 changes: 60 additions & 0 deletions roles/nat64_appliance/tasks/build_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# 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 required RPM packages
tags:
- packages
become: true
ansible.builtin.package:
name:
- python3-pip
- qemu-img
- dosfstools
- xfsprogs
state: present

- name: Install diskimage-builder in virtualenv
tags:
- packages
ansible.builtin.pip:
virtualenv_command: "python3 -m venv"
virtualenv: "{{ cifmw_nat64_appliance_venv_dir }}"
name:
- diskimage-builder
- setuptools

- name: Copy files to cifmw_nat64_appliance_dir
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ cifmw_nat64_appliance_workdir }}/{{ item }}"
mode: preserve
loop:
- "elements/"
- nat64-appliance.yaml

- name: Clone edpm-image-builder (reset-bls-entries dib element)
ansible.builtin.git:
repo: https://github.com/openstack-k8s-operators/edpm-image-builder.git
dest: "{{ cifmw_nat64_appliance_workdir }}/edpm-image-builder"
version: main

- name: Build the nat64-appliance image using DIB (with ci_script)
when: cifmw_nat64_appliance_use_ci_script | bool
ansible.builtin.include_tasks: build_with_ci_script.yml

- name: Build the nat64-appliance image using DIB (with shell)
when: not (cifmw_nat64_appliance_use_ci_script | bool)
ansible.builtin.include_tasks: build_with_shell.yml
28 changes: 28 additions & 0 deletions roles/nat64_appliance/tasks/build_with_ci_script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# 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: Build the nat64-appliance image using DIB (with ci_script)
become: "{{ cifmw_nat64_appliance_run_dib_as_root | default(false) | bool }}"
environment:
ELEMENTS_PATH: "{{ cifmw_nat64_appliance_workdir }}/elements:{{ cifmw_nat64_appliance_workdir }}/edpm-image-builder/dib/"
DIB_IMAGE_CACHE: "{{ cifmw_nat64_appliance_workdir }}/cache"
DIB_DEBUG_TRACE: '1'
cifmw.general.ci_script:
chdir: "{{ cifmw_nat64_appliance_workdir }}"
output_dir: "{{ cifmw_nat64_appliance_basedir }}/artifacts"
creates: "{{ cifmw_nat64_appliance_workdir }}/nat64-appliance.qcow2"
script: "{{ cifmw_nat64_appliance_venv_dir }}/bin/diskimage-builder nat64-appliance.yaml {{ extra_args | default('') }}"
executable: "/bin/bash"
28 changes: 28 additions & 0 deletions roles/nat64_appliance/tasks/build_with_shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# 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: Build the nat64-appliance image using DIB (with shell)
become: "{{ cifmw_nat64_appliance_run_dib_as_root | default(false) | bool }}"
environment:
ELEMENTS_PATH: "{{ cifmw_nat64_appliance_workdir }}/elements:{{ cifmw_nat64_appliance_workdir }}/edpm-image-builder/dib/"
DIB_IMAGE_CACHE: "{{ cifmw_nat64_appliance_workdir }}/cache"
DIB_DEBUG_TRACE: '1'
ansible.builtin.shell: |
{{ cifmw_nat64_appliance_venv_dir }}/bin/diskimage-builder nat64-appliance.yaml {{ extra_args | default('') }}
args:
chdir: "{{ cifmw_nat64_appliance_workdir }}"
creates: "{{ cifmw_nat64_appliance_workdir }}/nat64-appliance.qcow2"
executable: /bin/bash
51 changes: 1 addition & 50 deletions roles/nat64_appliance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,56 +32,7 @@
- name: Build NAT64 appliance image from source
when:
- cifmw_nat64_appliance_image_url | length == 0
block:
- name: Install required RPM packages
tags:
- packages
become: true
ansible.builtin.package:
name:
- python3-pip
- qemu-img
- dosfstools
- xfsprogs
state: present

- name: Install diskimage-builder in virtualenv
tags:
- packages
ansible.builtin.pip:
virtualenv_command: "python3 -m venv"
virtualenv: "{{ cifmw_nat64_appliance_venv_dir }}"
name:
- diskimage-builder
- setuptools

- name: Copy files to cifmw_nat64_appliance_dir
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ cifmw_nat64_appliance_workdir }}/{{ item }}"
mode: preserve
loop:
- "elements/"
- nat64-appliance.yaml

- name: Clone edpm-image-builder (reset-bls-entries dib element)
ansible.builtin.git:
repo: https://github.com/openstack-k8s-operators/edpm-image-builder.git
dest: "{{ cifmw_nat64_appliance_workdir }}/edpm-image-builder"
version: main

- name: Build the nat64-appliance image using DIB
become: "{{ cifmw_nat64_appliance_run_dib_as_root | default(false) | bool }}"
environment:
ELEMENTS_PATH: "{{ cifmw_nat64_appliance_workdir }}/elements:{{ cifmw_nat64_appliance_workdir }}/edpm-image-builder/dib/"
DIB_IMAGE_CACHE: "{{ cifmw_nat64_appliance_workdir }}/cache"
DIB_DEBUG_TRACE: '1'
cifmw.general.ci_script:
chdir: "{{ cifmw_nat64_appliance_workdir }}"
output_dir: "{{ cifmw_nat64_appliance_basedir }}/artifacts"
creates: "{{ cifmw_nat64_appliance_workdir }}/nat64-appliance.qcow2"
script: "{{ cifmw_nat64_appliance_venv_dir }}/bin/diskimage-builder nat64-appliance.yaml {{ extra_args | default('') }}"
executable: "/bin/bash"
ansible.builtin.include_tasks: build_image.yml

- name: Download pre-built NAT64 appliance image
when:
Expand Down