Skip to content

Commit

Permalink
Build docker image with latest ansible collections
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Zhang <[email protected]>
  • Loading branch information
keirazhang committed Jan 31, 2024
1 parent 3cdecc8 commit 56fd531
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
12 changes: 5 additions & 7 deletions docker_file/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ RUN pip3 install ansible-core==2.15.8
# ENV HTTPS_PROXY="https://proxy.xxxx.com:xxxx"
# Ansible 2.14.0 or later requires the locale encoding to be UTF-8
ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
COPY requirements.yml /tmp/requirements.yml
RUN ansible-galaxy install -r /tmp/requirements.yml
RUN ansible-galaxy collection install ansible.netcommon ansible.posix community.general community.vmware community.windows community.crypto

# Download latest 'ansible-vsphere-gos-validation' release to working dir
RUN curl -s https://api.github.com/repos/vmware/ansible-vsphere-gos-validation/releases/latest | grep "tarball_url" | cut -d "\"" -f 4 | xargs -n 1 wget -O test.tar.gz && \
tar -zxf test.tar.gz && \
mv vmware-ansible-vsphere-gos-validation*/* ./
RUN wget --no-check-certificate https://github.com/vmware/ansible-vsphere-gos-validation/archive/refs/heads/main.tar.gz -O /tmp/test.tar.gz && \
tar -zxf /tmp/test.tar.gz -C /tmp && \
mv /tmp/ansible-vsphere-gos-validation-main/* ./

# Clean up unused files
RUN rm -rf test.tar.gz vmware-ansible-vsphere-gos-validation* && \
tdnf clean all && \
RUN tdnf clean all && \
rm -rf /var/cache/* /root/.cache/pip/* /var/log/* /tmp/* /root/.ansible/tmp/*

# Known issue: ping: socket SOCK_DGRAM 1: Permission denied, Kernel bug workaround
Expand Down
17 changes: 4 additions & 13 deletions docker_file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@
## Build docker image
Build a new docker image with version tag vX.Y for latest release.
```
cp -f ../requirements.yml .
docker build . -t projects.registry.vmware.com/gos_cert/ansible-vsphere-gos-validation:vX.Y
docker build . -t ansible-vsphere-gos-validation:vX.Y
```

## Run docker container to test the new docker image
```
docker run -it --privileged projects.registry.vmware.com/gos_cert/ansible-vsphere-gos-validation:vX.Y
docker run -it --privileged ansible-vsphere-gos-validation:vX.Y
```

## Push new docker image to registry
## Tag the docker image as latest
```
docker login projects.registry.vmware.com
docker push projects.registry.vmware.com/gos_cert/ansible-vsphere-gos-validation:vX.Y
```

## Tag the docker image as latest one and push it
```
docker image tag projects.registry.vmware.com/gos_cert/ansible-vsphere-gos-validation:vX.Y projects.registry.vmware.com/gos_cert/ansible-vsphere-gos-validation:latest
docker login projects.registry.vmware.com
docker push projects.registry.vmware.com/gos_cert/ansible-vsphere-gos-validation:latest
docker image tag ansible-vsphere-gos-validation:vX.Y ansible-vsphere-gos-validation:latest
```
24 changes: 8 additions & 16 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@
# Note: this requirements.yml file is used to specify what Ansible collections are
# needed to launch the testing
collections:
- name: ansible.netcommon
version: 6.0.0
- name: ansible.posix
version: 1.5.4
- name: ansible.utils
version: 3.0.0
- name: ansible.windows
version: 2.2.0
- name: community.crypto
version: 2.17.1
- name: community.general
version: 8.3.0
- name: community.vmware
version: 4.1.0
- name: community.windows
version: 2.1.0
- ansible.netcommon
- ansible.posix
- ansible.utils
- ansible.windows
- community.crypto
- community.general
- community.vmware
- community.windows

0 comments on commit 56fd531

Please sign in to comment.