Add container registry login
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2023-03-09 12:45:51 +01:00
parent 462aebdf17
commit b6a03484e1
4 changed files with 31 additions and 7 deletions

View File

@ -39,30 +39,38 @@ steps:
- | - |
packer validate \ packer validate \
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \ -var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
-var docker_username=$${DOCKER_USERNAME} \
-var docker_password=$${DOCKER_PASSWORD} \
-var repo_username=$${REPO_USERNAME} \ -var repo_username=$${REPO_USERNAME} \
-var repo_password=$${REPO_PASSWORD} \ -var repo_password=$${REPO_PASSWORD} \
-var vsphere_password=$${VSPHERE_PASSWORD} \
-var ssh_password=$${SSH_PASSWORD} \ -var ssh_password=$${SSH_PASSWORD} \
-var vsphere_password=$${VSPHERE_PASSWORD} \
./packer ./packer
- | - |
packer build \ packer build \
-on-error=cleanup -timestamp-ui \ -on-error=cleanup -timestamp-ui \
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \ -var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
-var docker_username=$${DOCKER_USERNAME} \
-var docker_password=$${DOCKER_PASSWORD} \
-var repo_username=$${REPO_USERNAME} \ -var repo_username=$${REPO_USERNAME} \
-var repo_password=$${REPO_PASSWORD} \ -var repo_password=$${REPO_PASSWORD} \
-var vsphere_password=$${VSPHERE_PASSWORD} \
-var ssh_password=$${SSH_PASSWORD} \ -var ssh_password=$${SSH_PASSWORD} \
-var vsphere_password=$${VSPHERE_PASSWORD} \
./packer ./packer
environment: environment:
VSPHERE_PASSWORD: DOCKER_USERNAME:
from_secret: vsphere_password from_secret: docker_username
SSH_PASSWORD: DOCKER_PASSWORD:
from_secret: ssh_password from_secret: docker_password
# PACKER_LOG: 1
REPO_USERNAME: REPO_USERNAME:
from_secret: repo_username from_secret: repo_username
REPO_PASSWORD: REPO_PASSWORD:
from_secret: repo_password from_secret: repo_password
# PACKER_LOG: 1 SSH_PASSWORD:
from_secret: ssh_password
VSPHERE_PASSWORD:
from_secret: vsphere_password
volumes: volumes:
- name: output - name: output
path: /output path: /output

View File

@ -37,6 +37,15 @@
loop_control: loop_control:
label: "{{ item.source }}" label: "{{ item.source }}"
- name: Log in to container registry
ansible.builtin.shell:
cmd: >-
skopeo login \
docker.io \
--username={{ docker_username }} \
--password={{ docker_password }}
no_log: true
- name: Pull and store containerimages - name: Pull and store containerimages
ansible.builtin.shell: ansible.builtin.shell:
cmd: >- cmd: >-

View File

@ -37,6 +37,8 @@ build {
extra_arguments = [ extra_arguments = [
"--extra-vars", "appliancetype=${source.name}", "--extra-vars", "appliancetype=${source.name}",
"--extra-vars", "ansible_ssh_pass=${var.ssh_password}", "--extra-vars", "ansible_ssh_pass=${var.ssh_password}",
"--extra-vars", "docker_username=${var.docker_username}",
"--extra-vars", "docker_password=${var.docker_password}"
"--extra-vars", "repo_username=${var.repo_username}", "--extra-vars", "repo_username=${var.repo_username}",
"--extra-vars", "repo_password=${var.repo_password}" "--extra-vars", "repo_password=${var.repo_password}"
] ]

View File

@ -28,3 +28,8 @@ local "iso_authenticatedurl" {
expression = "https://${var.repo_username}:${var.repo_password}@${var.iso_url}" expression = "https://${var.repo_username}:${var.repo_password}@${var.iso_url}"
sensitive = true sensitive = true
} }
variable "docker_username" {}
variable "docker_password" {
sensitive = true
}