1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00

Merge pull request #418 from Comradephate/patch-1

Divorce the "local docker install" portion of the install playbook from the image build + push logic
This commit is contained in:
Matthew Jones 2017-10-27 12:31:09 -04:00 committed by GitHub
commit 63cf681369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 26 deletions

View File

@ -330,6 +330,10 @@ If you wish to tag and push built images to a Docker registry, set the following
> Username of the user that will push images to the registry. Defaults to *developer*. > Username of the user that will push images to the registry. Defaults to *developer*.
*docker_remove_local_images*
> Due to the way that the docker_image module behaves, images will not be pushed to a remote repository if they are present locally. Set this to delete local versions of the images that will be pushed to the remote. This will fail if containers are currently running from those images.
**Note** **Note**
> These settings are ignored if using official images > These settings are ignored if using official images

View File

@ -4,3 +4,4 @@
gather_facts: false gather_facts: false
roles: roles:
- { role: image_build } - { role: image_build }
- { role: image_push, when: "docker_registry is defined" }

View File

@ -1,7 +1,7 @@
# main.yml # main.yml
--- ---
- include: check_openshift.yml - include_tasks: check_openshift.yml
when: openshift_host is defined and openshift_host != '' when: openshift_host is defined and openshift_host != ''
- include: check_docker.yml - include_tasks: check_docker.yml
when: openshift_host is not defined or openshift_host == '' when: openshift_host is not defined or openshift_host == ''

View File

@ -0,0 +1,43 @@
---
- name: Remove local images to ensure proper push behavior
# TODO: this code will not be necessary if and when docker_image can be configured to push if the image
# Already exists locally
# Pull request: https://github.com/ansible/ansible/pull/31863
block:
- name: Remove web image
docker_image:
name: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_web_image }}"
tag: "{{ awx_version }}"
state: absent
- name: Remove task image
docker_image:
name: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_task_image }}"
tag: "{{ awx_version }}"
state: absent
delegate_to: localhost
when: docker_remove_local_images|default(False)
- name: Tag and Push Container Images
block:
- name: Tag and push web image to registry
docker_image:
name: "{{ awx_web_image }}"
repository: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_web_image }}"
tag: "{{ awx_version }}"
push: yes
- name: Tag and push task image to registry
docker_image:
name: "{{ awx_task_image }}"
repository: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_task_image }}"
tag: "{{ awx_version }}"
push: yes
delegate_to: localhost
- name: Set full image path for Registry
set_fact:
awx_web_docker_actual_image: >-
{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_web_image }}:{{ awx_version }}
awx_task_docker_actual_image: >-
{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_task_image }}:{{ awx_version }}

View File

@ -7,4 +7,3 @@
- { role: image_build, when: "dockerhub_base is not defined" } - { role: image_build, when: "dockerhub_base is not defined" }
- { role: openshift, when: "openshift_host is defined" } - { role: openshift, when: "openshift_host is defined" }
- { role: local_docker, when: "openshift_host is not defined" } - { role: local_docker, when: "openshift_host is not defined" }

View File

@ -39,6 +39,11 @@ host_port=80
# docker_registry_repository=awx # docker_registry_repository=awx
# docker_registry_username=developer # docker_registry_username=developer
# Docker_image will not attempt to push to remote if the image already exists locally
# Set this to true to delete images from docker on the build host so that they are pushed to the remote repository
# docker_remove_local_images=False
# Set pg_hostname if you have an external postgres server, otherwise # Set pg_hostname if you have an external postgres server, otherwise
# a new postgres service will be created # a new postgres service will be created
# pg_hostname=postgresql # pg_hostname=postgresql

View File

@ -65,29 +65,9 @@
timeout: 300 timeout: 300
when: ansible_connection != "local" and docker_registry is not defined when: ansible_connection != "local" and docker_registry is not defined
- name: Tag and push web image to registry - include_role:
docker_image: name: image_push
name: "{{ awx_web_image }}" when: docker_registry is defined and dockerhub_base is not defined
repository: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_web_image }}"
tag: "{{ awx_version }}"
push: yes
when: docker_registry is defined
delegate_to: localhost
- name: Tag and push task image to registry
docker_image:
name: "{{ awx_task_image }}"
repository: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_task_image }}"
tag: "{{ awx_version }}"
push: yes
when: docker_registry is defined
delegate_to: localhost
- name: Set full image path for Registry
set_fact:
awx_web_docker_actual_image: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_web_image }}"
awx_task_docker_actual_image: "{{ docker_registry }}/{{ docker_registry_repository }}/{{ awx_task_image }}"
when: docker_registry is defined
- name: Set full image path for local install - name: Set full image path for local install
set_fact: set_fact: