Skip to content

Commit

Permalink
Update ansible tasks to install quay with sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
harishsurf committed May 1, 2024
1 parent 10002b4 commit 6f2bef1
Show file tree
Hide file tree
Showing 16 changed files with 58 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
EE_IMAGE=quay.io/quay/mirror-registry-ee:latest
EE_BASE_IMAGE=registry.redhat.io/ansible-automation-platform-22/ee-minimal-rhel8:1.0.0-249
EE_BUILDER_IMAGE=registry.redhat.io/ansible-automation-platform-22/ansible-builder-rhel8:1.1.0-103
POSTGRES_IMAGE=registry.redhat.io/rhel8/postgresql-10:1-203.1669834630
QUAY_IMAGE=registry.redhat.io/quay/quay-rhel8:v3.8.15
# POSTGRES_IMAGE=registry.redhat.io/rhel8/postgresql-10:1-203.1669834630
QUAY_IMAGE=quay.io/omr-sqlite/omrrepo:workingsqlite
REDIS_IMAGE=registry.redhat.io/rhel8/redis-6:1-92.1669834635
PAUSE_IMAGE=registry.access.redhat.com/ubi8/pause:8.7-6
13 changes: 3 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ARG QUAY_IMAGE=${QUAY_IMAGE}
ARG EE_IMAGE=${EE_IMAGE}
ARG EE_BASE_IMAGE=${EE_BASE_IMAGE}
ARG EE_BUILDER_IMAGE=${EE_BUILDER_IMAGE}
ARG POSTGRES_IMAGE=${POSTGRES_IMAGE}
ARG REDIS_IMAGE=${REDIS_IMAGE}
ARG PAUSE_IMAGE=${PAUSE_IMAGE}

Expand All @@ -14,7 +13,6 @@ FROM registry.access.redhat.com/ubi8:latest AS cli
ARG RELEASE_VERSION=${RELEASE_VERSION}
ARG QUAY_IMAGE=${QUAY_IMAGE}
ARG EE_IMAGE=${EE_IMAGE}
ARG POSTGRES_IMAGE=${POSTGRES_IMAGE}
ARG REDIS_IMAGE=${REDIS_IMAGE}
ARG PAUSE_IMAGE=${PAUSE_IMAGE}

Expand All @@ -34,11 +32,10 @@ ENV RELEASE_VERSION=${RELEASE_VERSION}
ENV EE_IMAGE=${EE_IMAGE}
ENV QUAY_IMAGE=${QUAY_IMAGE}
ENV REDIS_IMAGE=${REDIS_IMAGE}
ENV POSTGRES_IMAGE=${POSTGRES_IMAGE}
ENV PAUSE_IMAGE=${PAUSE_IMAGE}

RUN go build -v \
-ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}" \
-ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE}" \
-o mirror-registry

# Create Ansible Execution Environment
Expand Down Expand Up @@ -71,7 +68,6 @@ COPY ansible-runner/context/app /runner
# Pull in Quay dependencies
FROM $QUAY_IMAGE as quay
FROM $REDIS_IMAGE as redis
FROM $POSTGRES_IMAGE as postgres
FROM $PAUSE_IMAGE as pause

# Create mirror registry archive
Expand All @@ -87,16 +83,13 @@ RUN tar -cvf execution-environment.tar -C /ansible .
COPY --from=redis / /redis
RUN tar -cvf redis.tar -C /redis .

COPY --from=postgres / /postgres
RUN tar -cvf postgres.tar -C /postgres .

COPY --from=quay / /quay
RUN tar -cvf quay.tar -C /quay .

COPY --from=cli /cli/mirror-registry .

# Bundle quay, redis, postgres, and pause into a single archive
RUN tar -cvf image-archive.tar quay.tar redis.tar postgres.tar pause.tar
# Bundle quay, redis and pause into a single archive
RUN tar -cvf image-archive.tar quay.tar redis.tar pause.tar

# Bundle mirror registry archive
RUN tar -czvf mirror-registry.tar.gz image-archive.tar execution-environment.tar mirror-registry
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile.online
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ FROM registry.redhat.io/ubi8:latest AS cli
ARG RELEASE_VERSION=${RELEASE_VERSION}
ARG QUAY_IMAGE=${QUAY_IMAGE}
ARG EE_IMAGE=${EE_IMAGE}
ARG POSTGRES_IMAGE=${POSTGRES_IMAGE}
ARG REDIS_IMAGE=${REDIS_IMAGE}
ARG PAUSE_IMAGE=${PAUSE_IMAGE}

Expand All @@ -29,11 +28,10 @@ ENV RELEASE_VERSION=${RELEASE_VERSION}
ENV EE_IMAGE=${EE_IMAGE}
ENV QUAY_IMAGE=${QUAY_IMAGE}
ENV REDIS_IMAGE=${REDIS_IMAGE}
ENV POSTGRES_IMAGE=${POSTGRES_IMAGE}
ENV PAUSE_IMAGE=${PAUSE_IMAGE}

RUN go build -v \
-ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE} -X github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}" \
-ldflags "-X github.com/quay/mirror-registry/cmd.releaseVersion=${RELEASE_VERSION} -X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X github.com/quay/mirror-registry/cmd.pauseImage=${PAUSE_IMAGE} -X github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE} -X github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE}" \
-o mirror-registry

# Create Ansible Execution Environment
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ all:

build-golang-executable:
$(CLIENT) run --rm -v ${PWD}:/usr/src:Z -w /usr/src docker.io/golang:1.16 go build -v \
-ldflags "-X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X 'github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE}' -X 'github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE}' -X 'github.com/quay/mirror-registry/cmd.postgresImage=${POSTGRES_IMAGE}'" \
-ldflags "-X github.com/quay/mirror-registry/cmd.eeImage=${EE_IMAGE} -X 'github.com/quay/mirror-registry/cmd.quayImage=${QUAY_IMAGE}' -X 'github.com/quay/mirror-registry/cmd.redisImage=${REDIS_IMAGE}'" \
-o mirror-registry;

build-online-zip:
Expand All @@ -19,7 +19,6 @@ build-online-zip:
--build-arg EE_IMAGE=${EE_IMAGE} \
--build-arg EE_BASE_IMAGE=${EE_BASE_IMAGE} \
--build-arg EE_BUILDER_IMAGE=${EE_BUILDER_IMAGE} \
--build-arg POSTGRES_IMAGE=${POSTGRES_IMAGE} \
--build-arg REDIS_IMAGE=${REDIS_IMAGE} \
--build-arg PAUSE_IMAGE=${PAUSE_IMAGE} \
--file Dockerfile.online .
Expand All @@ -35,7 +34,6 @@ build-offline-zip:
--build-arg EE_IMAGE=${EE_IMAGE} \
--build-arg EE_BASE_IMAGE=${EE_BASE_IMAGE} \
--build-arg EE_BUILDER_IMAGE=${EE_BUILDER_IMAGE} \
--build-arg POSTGRES_IMAGE=${POSTGRES_IMAGE} \
--build-arg REDIS_IMAGE=${REDIS_IMAGE} \
--build-arg PAUSE_IMAGE=${PAUSE_IMAGE} \
--file Dockerfile .
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This application will allow user to easily install Quay and its required compone
Download one of the installer package from our [releases](https://github.com/quay/mirror-registry/releases) page:

- offline version (contains all required images to run Quay)
- online version (additional container images to run Quay and Postgres will be downloaded by the installer)
- online version (additional container images to run Quay and Redis will be downloaded by the installer)

### Running the installer

Expand All @@ -32,7 +32,7 @@ The following flags are also available:
--quayHostname The value to set SERVER_HOSTNAME in the Quay config.yaml. This defaults to <targetHostname>:8443.
--quayRoot -r The folder where quay persistent quay config data is saved. This defaults to $HOME/quay-install.
--quayStorage The folder where quay persistent storage data is saved. This defaults to a Podman named volume 'quay-storage'. Root is required to uninstall.
--pgStorage The folder where postgres persistent storage data is saved. This defaults to a Podman named volume 'pg-storage'. Root is required to uninstall.
--sqliteStorage The folder where quay sqlite db data is saved. This defaults to a Podman named volume 'sqlite-storage'. Root is required to uninstall.
--ssh-key -k The path of your ssh identity key. This defaults to ~/.ssh/quay_installer.
--sslCert The path to the SSL certificate Quay should use.
--sslCheckSkip Whether or not to check the certificate hostname against the SERVER_HOSTNAME in config.yaml.
Expand Down Expand Up @@ -68,7 +68,7 @@ Behind the scenes, Ansible is using `ssh -i ~/.ssh/my_ssh_key someuser@some.remo
This command will make the following changes to your machine

- Generate trusted SSH keys, if not supplied, in case the deployment target is the local host (required since the installer is ansible-based)
- Pulls Quay, Redis, and Postgres images from `registry.redhat.io` (if using online installer)
- Pulls Quay and Redis images from `registry.redhat.io` (if using online installer)
- Sets up systemd files on host machine to ensure that container runtimes are persistent
- Creates the folder defined by `--quayRoot` (default: `$HOME/quay-install`) contains install files, local storage, and config bundle.
- Installs Quay and creates an initial user called `init` with an auto-generated password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

- name: Loading Quay if quay.tar exists
shell:
cmd: podman image import --change 'ENV container=oci' --change 'ENV PATH=/app/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' --change 'ENV PYTHONUNBUFFERED=1' --change 'ENV PYTHONIOENCODING=UTF-8' --change 'ENV LC_ALL=C.UTF-8' --change 'ENV LANG=C.UTF-8' --change 'ENV QUAYDIR=/quay-registry' --change 'ENV QUAYCONF=/quay-registry/conf' --change 'ENV QUAYRUN=/quay-registry/conf' --change 'ENV QUAYPATH=/quay-registry' --change 'ENV PYTHONUSERBASE=/app' --change 'ENV PYTHONPATH=/quay-registry' --change 'ENV TZ=UTC' --change 'ENV RED_HAT_QUAY=true' --change 'ENTRYPOINT=["dumb-init","--","/quay-registry/quay-entrypoint.sh"]' --change 'WORKDIR=/quay-registry' --change 'EXPOSE=7443' --change 'EXPOSE=8080' --change 'EXPOSE=8443' --change 'VOLUME=/conf/stack' --change 'VOLUME=/datastorage' --change 'VOLUME=/tmp' --change 'VOLUME=/var/log' --change 'USER=1001' --change 'CMD ["registry"]' - {{ quay_image }} < {{ quay_root }}/quay.tar
cmd: podman image import --change 'ENV container=oci' --change 'ENV PATH=/app/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' --change 'ENV PYTHONUNBUFFERED=1' --change 'ENV PYTHONIOENCODING=UTF-8' --change 'ENV LC_ALL=C.UTF-8' --change 'ENV LANG=C.UTF-8' --change 'ENV QUAYDIR=/quay-registry' --change 'ENV QUAYCONF=/quay-registry/conf' --change 'ENV QUAYRUN=/quay-registry/conf' --change 'ENV QUAYPATH=/quay-registry' --change 'ENV PYTHONUSERBASE=/app' --change 'ENV PYTHONPATH=/quay-registry' --change 'ENV TZ=UTC' --change 'ENV RED_HAT_QUAY=true' --change 'ENTRYPOINT=["dumb-init","--","/quay-registry/quay-entrypoint.sh"]' --change 'WORKDIR=/quay-registry' --change 'EXPOSE=7443' --change 'EXPOSE=8080' --change 'EXPOSE=8443' --change 'VOLUME=/conf/stack' --change 'VOLUME=/datastorage' --change 'VOLUME=/sqlite/data' --change 'VOLUME=/tmp' --change 'VOLUME=/var/log' --change 'USER=1001' --change 'CMD ["registry"]' - {{ quay_image }} < {{ quay_root }}/quay.tar
when: p.stat.exists and local_install == "false"

- name: Loading Postgres if postgres.tar exists
shell:
cmd: podman image import --change 'ENV PATH=/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' --change 'ENV STI_SCRIPTS_URL=image:///usr/libexec/s2i' --change 'ENV STI_SCRIPTS_PATH=/usr/libexec/s2i' --change 'ENV APP_ROOT=/opt/app-root' --change 'ENV APP_DATA=/opt/app-root' --change 'ENV HOME=/var/lib/pgsql' --change 'ENV PLATFORM=el8' --change 'ENV POSTGRESQL_VERSION=10' --change 'ENV POSTGRESQL_PREV_VERSION=9.6' --change 'ENV PGUSER=postgres' --change 'ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql' --change 'ENTRYPOINT=["container-entrypoint"]' --change 'WORKDIR=/opt/app-root/src' --change 'EXPOSE=5432' --change 'USER=26' --change 'CMD ["run-postgresql"]' - {{ postgres_image }} < {{ quay_root }}/postgres.tar
when: p.stat.exists and local_install == "false"
# - name: Loading Postgres if postgres.tar exists
# shell:
# cmd: podman image import --change 'ENV PATH=/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' --change 'ENV STI_SCRIPTS_URL=image:///usr/libexec/s2i' --change 'ENV STI_SCRIPTS_PATH=/usr/libexec/s2i' --change 'ENV APP_ROOT=/opt/app-root' --change 'ENV APP_DATA=/opt/app-root' --change 'ENV HOME=/var/lib/pgsql' --change 'ENV PLATFORM=el8' --change 'ENV POSTGRESQL_VERSION=10' --change 'ENV POSTGRESQL_PREV_VERSION=9.6' --change 'ENV PGUSER=postgres' --change 'ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql' --change 'ENTRYPOINT=["container-entrypoint"]' --change 'WORKDIR=/opt/app-root/src' --change 'EXPOSE=5432' --change 'USER=26' --change 'CMD ["run-postgresql"]' - {{ postgres_image }} < {{ quay_root }}/postgres.tar
# when: p.stat.exists and local_install == "false"
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
- name: Expand pg_storage
shell: 'echo {{ pg_storage }}'
register: expanded_pg_storage_output

- name: Expand quay_root
shell: 'echo {{ quay_root }}'
register: expanded_quay_root_output
Expand All @@ -10,8 +6,12 @@
shell: 'echo {{ quay_storage }}'
register: expanded_quay_storage_output

- name: Expand sqlite_storage
shell: 'echo {{ sqlite_storage }}'
register: expanded_sqlite_storage_output

- name: Set expanded variables
set_fact:
expanded_pg_storage: "{{ expanded_pg_storage_output.stdout }}"
expanded_sqlite_storage: "{{ expanded_sqlite_storage_output.stdout }}"
expanded_quay_root: "{{ expanded_quay_root_output.stdout }}"
expanded_quay_storage: "{{ expanded_quay_storage_output.stdout }}"
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@
state: present
when: "quay_storage.startswith('/')"

- name: Create necessary directory for Postgres persistent data
- name: Create necessary directory for sqlite data
ansible.builtin.file:
path: "{{ pg_storage }}"
path: "{{ sqlite_storage }}"
state: directory
recurse: yes
when: "pg_storage.startswith('/')"
when: "sqlite_storage.startswith('/')"

- name: Set permissions on local storage directory
ansible.posix.acl:
path: "{{ pg_storage }}"
entity: 26
path: "{{ sqlite_storage }}"
entity: 1001
etype: user
permissions: wx
state: present
when: "pg_storage.startswith('/')"
when: "sqlite_storage.startswith('/')"

# - name: Set write permissions for the /tmp/cer directory
# ansible.builtin.acl:
# path: /tmp/cer
# entity: 1001
# etype: user
# permissions: write
# state: present

- name: Create necessary directory for Quay config bundle
ansible.builtin.file:
Expand Down Expand Up @@ -138,10 +146,10 @@
state: present
name: quay-storage

- name: Create Postgres Storage named volume
- name: Create Sqlite Storage named volume
containers.podman.podman_volume:
state: present
name: pg-storage
name: sqlite-storage

- name: Start Quay service
systemd:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
set_fact:
secret_key: "{{ lookup('community.general.random_string', length=48, base64=True) }}"
database_secret_key: "{{ lookup('community.general.random_string', length=48, base64=True) }}"
pgdb_password: "{{ lookup('community.general.random_string', length=24, special=False) }}"
redis_password: "{{ lookup('community.general.random_string', length=24, special=False) }}"
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
containers.podman.podman_volume:
state: absent
name: quay-storage
when: auto_approve|bool == true and quay_storage == "pg-storage"
when: auto_approve|bool == true and quay_storage == "quay-storage"

- name: Delete Postgres Storage named volume
- name: Delete Sqlite Storage named volume
containers.podman.podman_volume:
state: absent
name: pg-storage
when: auto_approve|bool == true and pg_storage == "pg-storage"
name: sqlite-storage
when: auto_approve|bool == true and sqlite_storage == "sqlite-storage"

- name: Delete Postgres Password Secret
containers.podman.podman_secret:
Expand All @@ -68,12 +68,12 @@
become: yes
when: auto_approve|bool == true and quay_storage.startswith('/')

- name: Delete necessary directory for Postgres persistent data
- name: Delete necessary directory for Sqlite storage data
ansible.builtin.file:
path: "{{ pg_storage }}"
path: "{{ sqlite_storage }}"
state: absent
become: yes
when: auto_approve|bool == true and pg_storage.startswith('/')
when: auto_approve|bool == true and sqlite_storage.startswith('/')

- name: Delete Install Directory
file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ BUILDLOGS_REDIS:
host: localhost
password: {{ redis_password }}
port: 6379
{# DATABASE_SECRET_KEY: {{ database_secret_key }} #}
DATABASE_SECRET_KEY: {{ database_secret_key }}
{# DB_URI: postgresql://user:{{ pgdb_password }}@localhost/quay #}
DB_URI: sqlite:///quay-registry/sqlite/data/quay_sqlite.db
DB_URI: sqlite:////quay-registry/sqlite/data/quay_sqlite.db
DEFAULT_TAG_EXPIRATION: 2w
DISTRIBUTED_STORAGE_DEFAULT_LOCATIONS: []
DISTRIBUTED_STORAGE_PREFERENCE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ExecStartPre=-/bin/rm -f %t/%n-pid %t/%n-cid
ExecStart=/usr/bin/podman run \
--name quay-app \
-v {{ expanded_quay_root }}/quay-config:/quay-registry/conf/stack:Z \
-v {{ expanded_sqlite_storage }}/quay-config:/quay-registry/sqlite/data:Z \
-v {{ expanded_sqlite_storage }}:/quay-registry/sqlite/data:Z \
-v {{ expanded_quay_storage }}:/datastorage:Z \
--image-volume=ignore \
--pod=quay-pod \
Expand Down
Loading

0 comments on commit 6f2bef1

Please sign in to comment.