Merge pull request #11242 from shanemcd/awx-operator-ci-check

Add awx-operator CI check
This commit is contained in:
Shane McDonald
2021-10-13 10:28:23 -04:00
committed by GitHub
13 changed files with 137 additions and 53 deletions

View File

@@ -1,2 +1,3 @@
awx/ui/node_modules awx/ui/node_modules
Dockerfile Dockerfile
.git

View File

@@ -175,3 +175,41 @@ jobs:
run: | run: |
docker run -u $(id -u) --rm -v ${{ github.workspace}}:/awx_devel/:Z \ docker run -u $(id -u) --rm -v ${{ github.workspace}}:/awx_devel/:Z \
--workdir=/awx_devel ghcr.io/${{ github.repository_owner }}/awx_devel:${{ env.BRANCH }} make ui-test --workdir=/awx_devel ghcr.io/${{ github.repository_owner }}/awx_devel:${{ env.BRANCH }} make ui-test
awx-operator:
runs-on: ubuntu-latest
steps:
- name: Checkout awx
uses: actions/checkout@v2
with:
path: awx
- name: Checkout awx-operator
uses: actions/checkout@v2
with:
repository: ansible/awx-operator
path: awx-operator
- name: Install playbook dependencies
run: |
python3 -m pip install docker
- name: Build AWX image
working-directory: awx
run: |
ansible-playbook -v tools/ansible/build.yml \
-e headless=yes \
-e awx_image=awx \
-e awx_image_tag=ci \
-e ansible_python_interpreter=$(which python3)
- name: Run test deployment with awx-operator
working-directory: awx-operator
run: |
python3 -m pip install -r molecule/requirements.txt
ansible-galaxy collection install -r molecule/requirements.yml
sudo rm -f $(which kustomize)
make kustomize
KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule test -s kind
env:
AWX_TEST_IMAGE: awx
AWX_TEST_VERSION: ci

View File

@@ -6,8 +6,11 @@ ignore: |
# vault files # vault files
awx/main/tests/data/ansible_utils/playbooks/valid/vault.yml awx/main/tests/data/ansible_utils/playbooks/valid/vault.yml
awx/ui/test/e2e/tests/smoke-vars.yml awx/ui/test/e2e/tests/smoke-vars.yml
awx/ui/node_modules
tools/docker-compose/_sources
extends: default extends: default
rules: rules:
line-length: disable line-length: disable
truthy: disable

View File

@@ -379,7 +379,7 @@ clean-ui:
awx/ui/node_modules: awx/ui/node_modules:
NODE_OPTIONS=--max-old-space-size=4096 $(NPM_BIN) --prefix awx/ui --loglevel warn ci NODE_OPTIONS=--max-old-space-size=4096 $(NPM_BIN) --prefix awx/ui --loglevel warn ci
$(UI_BUILD_FLAG_FILE): $(UI_BUILD_FLAG_FILE): awx/ui/node_modules
$(PYTHON) tools/scripts/compilemessages.py $(PYTHON) tools/scripts/compilemessages.py
$(NPM_BIN) --prefix awx/ui --loglevel warn run compile-strings $(NPM_BIN) --prefix awx/ui --loglevel warn run compile-strings
$(NPM_BIN) --prefix awx/ui --loglevel warn run build $(NPM_BIN) --prefix awx/ui --loglevel warn run build
@@ -391,7 +391,9 @@ $(UI_BUILD_FLAG_FILE):
cp -r awx/ui/build/static/media/* awx/public/static/media cp -r awx/ui/build/static/media/* awx/public/static/media
touch $@ touch $@
ui-release: awx/ui/node_modules $(UI_BUILD_FLAG_FILE)
ui-release: $(UI_BUILD_FLAG_FILE)
ui-devel: awx/ui/node_modules ui-devel: awx/ui/node_modules
@$(MAKE) -B $(UI_BUILD_FLAG_FILE) @$(MAKE) -B $(UI_BUILD_FLAG_FILE)
@@ -420,10 +422,17 @@ dev_build:
release_build: release_build:
$(PYTHON) setup.py release_build $(PYTHON) setup.py release_build
dist/$(SDIST_TAR_FILE): ui-release VERSION HEADLESS ?= no
ifeq ($(HEADLESS), yes)
dist/$(SDIST_TAR_FILE):
else
dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE)
endif
$(PYTHON) setup.py $(SDIST_COMMAND) $(PYTHON) setup.py $(SDIST_COMMAND)
ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz
sdist: dist/$(SDIST_TAR_FILE) sdist: dist/$(SDIST_TAR_FILE)
echo $(HEADLESS)
@echo "#############################################" @echo "#############################################"
@echo "Artifacts:" @echo "Artifacts:"
@echo dist/$(SDIST_TAR_FILE) @echo dist/$(SDIST_TAR_FILE)

View File

@@ -5,7 +5,10 @@
To build a custom awx image to use with the awx-operator, use the `build_image` role: To build a custom awx image to use with the awx-operator, use the `build_image` role:
``` ```
$ ansible-playbook tools/ansible/build.yml -v -e awx_image=registry.example.com/awx -e awx_version=test $ ansible-playbook tools/ansible/build.yml \
-e registry=registry.example.com \
-e awx_image=ansible/awx \
-e awx_version=test -v
``` ```
> Note: The development image (`make docker-compose-build`) will not work with the awx-operator, the UI is not built in that image, among other things (see Dockerfile.j2 for more info). > Note: The development image (`make docker-compose-build`) will not work with the awx-operator, the UI is not built in that image, among other things (see Dockerfile.j2 for more info).
@@ -21,7 +24,7 @@ $ docker push registry.example.com/awx:test
## Using this image with the awx-operator ## Using this image with the awx-operator
In the spec section of the `my-awx.yml` file described in the [install docs](./../INSTALL.md#deploy-awx), In the spec section of the `my-awx.yml` file described in the [install docs](./../INSTALL.md#deploy-awx),
specify the new custom image. specify the new custom image.
``` ```
spec: spec:

View File

@@ -2,7 +2,24 @@
- name: Build AWX Docker Images - name: Build AWX Docker Images
hosts: localhost hosts: localhost
gather_facts: true gather_facts: true
roles: tasks:
- {role: dockerfile} - name: Get version from SCM if not explicitly provided
- {role: image_build} shell: |
- {role: image_push, when: "docker_registry is defined"} python setup.py --version | cut -d + -f -1
args:
chdir: '../../'
register: setup_py_version
when: awx_version is not defined
- name: Set awx_version
set_fact:
awx_version: "{{ setup_py_version.stdout }}"
when: awx_version is not defined
- include_role:
name: dockerfile
- include_role:
name: image_build
- include_role:
name: image_push
when: push | default(false) | bool

View File

@@ -1,6 +1,7 @@
--- ---
build_dev: false build_dev: false
kube_dev: false kube_dev: false
headless: no
dockerfile_dest: '../..' dockerfile_dest: '../..'
dockerfile_name: 'Dockerfile' dockerfile_name: 'Dockerfile'
template_dest: '_build' template_dest: '_build'

View File

@@ -17,6 +17,4 @@ set -e
wait-for-migrations wait-for-migrations
awx-manage collectstatic --noinput --clear
supervisord -c /etc/supervisord.conf supervisord -c /etc/supervisord.conf

View File

@@ -11,6 +11,7 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8 ENV LC_ALL en_US.UTF-8
USER root USER root
# Install build dependencies # Install build dependencies
@@ -27,7 +28,9 @@ RUN dnf -y update && \
libffi-devel \ libffi-devel \
libtool-ltdl-devel \ libtool-ltdl-devel \
make \ make \
{% if not headless|bool %}
nodejs \ nodejs \
{% endif %}
nss \ nss \
openldap-devel \ openldap-devel \
patch \ patch \
@@ -44,6 +47,7 @@ RUN dnf -y update && \
RUN python3.8 -m ensurepip && pip3 install "virtualenv < 20" RUN python3.8 -m ensurepip && pip3 install "virtualenv < 20"
# Install & build requirements # Install & build requirements
ADD Makefile /tmp/Makefile ADD Makefile /tmp/Makefile
RUN mkdir /tmp/requirements RUN mkdir /tmp/requirements
@@ -54,18 +58,29 @@ ADD requirements/requirements.txt \
RUN cd /tmp && make requirements_awx RUN cd /tmp && make requirements_awx
ARG VERSION
ARG SETUPTOOLS_SCM_PRETEND_VERSION
ARG HEADLESS
{% if (build_dev|bool) or (kube_dev|bool) %} {% if (build_dev|bool) or (kube_dev|bool) %}
ADD requirements/requirements_dev.txt /tmp/requirements ADD requirements/requirements_dev.txt /tmp/requirements
RUN cd /tmp && make requirements_awx_dev RUN cd /tmp && make requirements_awx_dev
{% else %} {% else %}
# Use the distro provided npm to bootstrap our required version of node # Use the distro provided npm to bootstrap our required version of node
RUN npm install -g n && n 14.15.1 && dnf remove -y nodejs
{% if not headless|bool %}
RUN npm install -g n && n 14.15.1
{% endif %}
# Copy source into builder, build sdist, install it into awx venv # Copy source into builder, build sdist, install it into awx venv
COPY . /tmp/src/ COPY . /tmp/src/
WORKDIR /tmp/src/ WORKDIR /tmp/src/
RUN make sdist && \ RUN make sdist && /var/lib/awx/venv/awx/bin/pip install dist/awx.tar.gz
/var/lib/awx/venv/awx/bin/pip install dist/awx-$(cat VERSION).tar.gz
{% if not headless|bool %}
RUN /var/lib/awx/venv/awx/bin/awx-manage collectstatic --noinput --clear
{% endif %}
{% endif %} {% endif %}
# Final container(s) # Final container(s)

View File

@@ -1,2 +1,5 @@
--- ---
awx_image: quay.io/ansible/awx awx_image: ansible/awx
awx_image_tag: "{{ awx_version }}"
dockerfile_name: 'Dockerfile'
headless: no

View File

@@ -1,9 +1,4 @@
--- ---
- name: Set global version if not provided
set_fact:
awx_version: "{{ lookup('file', playbook_dir + '/../../VERSION') }}"
when: awx_version is not defined
- name: Verify awx-logos directory exists for official install - name: Verify awx-logos directory exists for official install
stat: stat:
path: "../../../awx-logos" path: "../../../awx-logos"
@@ -17,11 +12,19 @@
dest: "../../awx/ui/public/static/media/" dest: "../../awx/ui/public/static/media/"
when: awx_official|default(false)|bool when: awx_official|default(false)|bool
- set_fact:
command_to_run: |
docker build -t {{ awx_image }}:{{ awx_image_tag }} \
-f {{ dockerfile_name }} \
--build-arg VERSION={{ awx_version }} \
--build-arg SETUPTOOLS_SCM_PRETEND_VERSION={{ awx_version }} \
--build-arg HEADLESS={{ headless }} \
.
# Calling Docker directly because docker-py doesnt support BuildKit # Calling Docker directly because docker-py doesnt support BuildKit
- name: Build AWX image - name: Build AWX image
command: docker build -t {{ awx_image }}:{{ awx_version }} -f ../../{{ dockerfile_name }} ../.. shell: "{{ command_to_run }}"
environment:
- name: Tag awx images as latest DOCKER_BUILDKIT: 1
command: "docker tag {{ item }}:{{ awx_version }} {{ item }}:latest" args:
with_items: chdir: "{{ playbook_dir }}/../../"
- "{{ awx_image }}"

View File

@@ -0,0 +1,4 @@
---
registry: quay.io
awx_image: ansible/awx
awx_image_tag: "{{ awx_version }}"

View File

@@ -1,33 +1,22 @@
--- ---
- name: Authenticate with Docker registry if registry password given - name: Authenticate with Docker registry if registry password given
docker_login: docker_login:
registry: "{{ docker_registry }}" registry: "{{ registry }}"
username: "{{ docker_registry_username }}" username: "{{ registry_username }}"
password: "{{ docker_registry_password }}" password: "{{ registry_password }}"
reauthorize: true reauthorize: true
when: docker_registry is defined and docker_registry_password is defined when:
- registry is defined
- name: Remove local images to ensure proper push behavior - registry_username is defined
block: - registry_password is defined
- name: Remove awx image
docker_image:
name: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_image }}"
tag: "{{ awx_version }}"
state: absent
- name: Tag and Push Container Images - name: Tag and Push Container Images
block: docker_image:
- name: Tag and push awx image to registry name: "{{ awx_image }}:{{ awx_version }}"
docker_image: repository: "{{ registry }}/{{ awx_image }}:{{ item }}"
name: "{{ awx_image }}" force_tag: yes
repository: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_image }}" push: true
tag: "{{ item }}" source: local
push: true with_items:
with_items: - "latest"
- "latest" - "{{ awx_version }}"
- "{{ awx_version }}"
- name: Set full image path for Registry
set_fact:
awx_docker_actual_image: >-
{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_image }}:{{ awx_version }}