Add support for installing AWX from official images

* New options in the inventory file
* Add defaults to some variables
This commit is contained in:
Matthew Jones
2017-09-25 21:52:23 -04:00
parent ddb689bded
commit 2e7b4529f8
4 changed files with 134 additions and 120 deletions

View File

@@ -16,14 +16,14 @@
delegate_to: localhost
register: logosdir
failed_when: logosdir.stat.isdir is not defined or not logosdir.stat.isdir
when: awx_official
when: awx_official|default(false)|bool
- name: Copy logos for inclusion in sdist
copy:
src: "../../awx-logos/awx/ui/client/assets"
dest: "../awx/ui/client/"
delegate_to: localhost
when: awx_official
when: awx_official|default(false)|bool
- name: Set sdist file name
set_fact:
@@ -59,7 +59,7 @@
tag: "{{ awx_version }}"
force: true
delegate_to: localhost
when: use_container_for_build|bool
when: use_container_for_build|default(true)|bool
- name: Build AWX distribution using container
docker_container:
@@ -74,14 +74,14 @@
volumes:
- ../:/awx:Z
delegate_to: localhost
when: use_container_for_build|bool
when: use_container_for_build|default(true)|bool
- name: Build AWX distribution locally
shell: make sdist
args:
chdir: ..
delegate_to: localhost
when: not use_container_for_build|bool
when: not use_container_for_build|default(true)|bool
- name: Set docker build base path
set_fact:

View File

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

View File

@@ -2,26 +2,22 @@ localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env pyth
[all:vars]
# Remove these lines if you want to run a local image build
# Otherwise the setup playbook will install the official Ansible images. Versions may
# be selected based on: latest, 1, 1.0, 1.0.0, 1.0.0.123
# by default the base will be used to search for ansible/awx_web and ansible/awx_task
dockerhub_base=ansible
dockerhub_version=latest
# This will create or update a default admin (superuser) account in AWX, if not provided
# then these default values are used
# default_admin_user=admin
# default_admin_password=password
# Use a local distribution build container image for building the AWX package
# This is helpful if you don't want to bother installing the build-time dependencies as
# it is taken care of already.
# NOTE: IMPORTANT: If you are running a mininshift install, using this container might not work
# if you are using certain drivers like KVM where the source tree can't be mapped
# into the build container.
# Thus this setting must be set to False which will trigger a local build. To view the
# typical dependencies that you might need to install see:
# installer/image_build/files/Dockerfile.sdist
use_container_for_build=true
# Build AWX with official logos
# Requires cloning awx-logos repo into the project root.
# Review the trademark guidelines at https://github.com/ansible/awx-logos/blob/master/TRADEMARKS.md
awx_official=false
# AWX Secret key
# It's *very* important that this stay the same between upgrades or you will lose the ability to decrypt
# your credentials
awx_secret_key=awxsecret
# Openshift Install
# Will need to set -e openshift_password=developer -e docker_registry_password=$(oc whoami -t)
@@ -34,7 +30,7 @@ awx_official=false
postgres_data_dir=/tmp/pgdocker
host_port=80
# Required for Openshift (unless you use an external registry), Optional for Standalone Docker install
# Required for Openshift (unless you use an external registry or DockerHub), Optional for Standalone Docker install
# Define if you want the image pushed to a registry. The container definition
# will also use these images
# docker_registry=172.30.1.1:5000
@@ -42,17 +38,28 @@ host_port=80
# docker_registry_username=developer
# Set pg_hostname if you have an external postgres server, otherwise
# a new ephemeral postgres service will be created
# a new postgres service will be created
# pg_hostname=postgresql
pg_username=awx
pg_password=awxpass
pg_database=awx
pg_port=5432
# AWX Secret key
# It's *very* important that this stay the same between upgrades or you will use the ability to decrypt
# your credentials
awx_secret_key=awxsecret
# Use a local distribution build container image for building the AWX package
# This is helpful if you don't want to bother installing the build-time dependencies as
# it is taken care of already.
# NOTE: IMPORTANT: If you are running a mininshift install, using this container might not work
# if you are using certain drivers like KVM where the source tree can't be mapped
# into the build container.
# Thus this setting must be set to False which will trigger a local build. To view the
# typical dependencies that you might need to install see:
# installer/image_build/files/Dockerfile.sdist
# use_container_for_build=true
# Build AWX with official logos
# Requires cloning awx-logos repo into the project root.
# Review the trademark guidelines at https://github.com/ansible/awx-logos/blob/master/TRADEMARKS.md
# awx_official=false
# Proxy
#http_proxy=http://proxy:3128

View File

@@ -1,99 +1,106 @@
---
- name: Export Docker web image if it isnt local and there isnt a registry defined
docker_image:
name: "{{ awx_web_image }}"
tag: "{{ awx_version }}"
archive_path: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_web_image }}_{{ awx_version }}.tar"
when: inventory_hostname != "localhost" and docker_registry is not defined
delegate_to: localhost
- name: Manage AWX Container Images
block:
- name: Export Docker web image if it isnt local and there isnt a registry defined
docker_image:
name: "{{ awx_web_image }}"
tag: "{{ awx_version }}"
archive_path: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_web_image }}_{{ awx_version }}.tar"
when: inventory_hostname != "localhost" and docker_registry is not defined
delegate_to: localhost
- name: Export Docker task image if it isnt local and there isnt a registry defined
docker_image:
name: "{{ awx_task_image }}"
tag: "{{ awx_version }}"
archive_path: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_task_image }}_{{ awx_version }}.tar"
when: inventory_hostname != "localhost" and docker_registry is not defined
delegate_to: localhost
- name: Export Docker task image if it isnt local and there isnt a registry defined
docker_image:
name: "{{ awx_task_image }}"
tag: "{{ awx_version }}"
archive_path: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_task_image }}_{{ awx_version }}.tar"
when: inventory_hostname != "localhost" and docker_registry is not defined
delegate_to: localhost
- name: Authenticate with Docker registry if registry password given
docker_login:
registry: "{{ docker_registry }}"
username: "{{ docker_registry_username }}"
password: "{{ docker_registry_password }}"
reauthorize: yes
when: docker_registry is defined and docker_registry_password is defined
delegate_to: localhost
- name: Authenticate with Docker registry if registry password given
docker_login:
registry: "{{ docker_registry }}"
username: "{{ docker_registry_username }}"
password: "{{ docker_registry_password }}"
reauthorize: yes
when: docker_registry is defined and docker_registry_password is defined
delegate_to: localhost
- name: Set docker base path
- name: Set docker base path
set_fact:
docker_deploy_base_path: "{{ awx_base_path|default('/tmp') }}/docker_deploy"
when: ansible_connection != "local" and docker_registry is not defined
- name: Ensure directory exists
file:
path: "{{ docker_deploy_base_path }}"
state: directory
when: ansible_connection != "local" and docker_registry is not defined
- name: Copy web image to docker execution
copy:
src: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_web_image }}_{{ awx_version }}.tar"
dest: "{{ docker_deploy_base_path }}/{{ awx_web_image }}_{{ awx_version }}.tar"
when: ansible_connection != "local" and docker_registry is not defined
- name: Copy task image to docker execution
copy:
src: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_task_image }}_{{ awx_version }}.tar"
dest: "{{ docker_deploy_base_path }}"
when: ansible_connection != "local" and docker_registry is not defined
- name: Load web image
docker_image:
name: "{{ awx_web_image }}"
tag: "{{ awx_version }}"
load_path: "{{ docker_deploy_base_path }}/{{ awx_web_image }}_{{ awx_version }}.tar"
timeout: 300
when: ansible_connection != "local" and docker_registry is not defined
- name: Load task image
docker_image:
name: "{{ awx_task_image }}"
tag: "{{ awx_version }}"
load_path: "{{ docker_deploy_base_path }}/{{ awx_task_image }}_{{ awx_version }}.tar"
timeout: 300
when: ansible_connection != "local" and docker_registry is not defined
- 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
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
set_fact:
awx_web_docker_actual_image: "{{ awx_web_image }}:{{ awx_version }}"
awx_task_docker_actual_image: "{{ awx_task_image }}:{{ awx_version }}"
when: docker_registry is not defined
when: dockerhub_base is not defined
- name: Set DockerHub Image Paths
set_fact:
docker_deploy_base_path: "{{ awx_base_path|default('/tmp') }}/docker_deploy"
when: ansible_connection != "local" and docker_registry is not defined
- name: Ensure directory exists
file:
path: "{{ docker_deploy_base_path }}"
state: directory
when: ansible_connection != "local" and docker_registry is not defined
- name: Copy web image to docker execution
copy:
src: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_web_image }}_{{ awx_version }}.tar"
dest: "{{ docker_deploy_base_path }}/{{ awx_web_image }}_{{ awx_version }}.tar"
when: ansible_connection != "local" and docker_registry is not defined
- name: Copy task image to docker execution
copy:
src: "{{ awx_local_base_config_path|default('/tmp') }}/{{ awx_task_image }}_{{ awx_version }}.tar"
dest: "{{ docker_deploy_base_path }}"
when: ansible_connection != "local" and docker_registry is not defined
- name: Load web image
docker_image:
name: "{{ awx_web_image }}"
tag: "{{ awx_version }}"
load_path: "{{ docker_deploy_base_path }}/{{ awx_web_image }}_{{ awx_version }}.tar"
timeout: 300
when: ansible_connection != "local" and docker_registry is not defined
- name: Load task image
docker_image:
name: "{{ awx_task_image }}"
tag: "{{ awx_version }}"
load_path: "{{ docker_deploy_base_path }}/{{ awx_task_image }}_{{ awx_version }}.tar"
timeout: 300
when: ansible_connection != "local" and docker_registry is not defined
- 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
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
set_fact:
awx_web_docker_actual_image: "{{ awx_web_image }}"
awx_task_docker_actual_image: "{{ awx_task_image }}"
when: docker_registry is not defined
## Docker-compose instead?
awx_web_docker_actual_image: "{{ dockerhub_base }}/awx_web:{{ dockerhub_version }}"
awx_task_docker_actual_image: "{{ dockerhub_base }}/awx_task:{{ dockerhub_version }}"
when: dockerhub_base is defined
- name: Activate postgres container
docker_container:
@@ -173,7 +180,7 @@
name: awx_web
state: started
restart_policy: unless-stopped
image: "{{ awx_web_docker_actual_image }}:{{ awx_version }}"
image: "{{ awx_web_docker_actual_image }}"
user: root
ports:
- "{{ host_port }}:8052"
@@ -201,7 +208,7 @@
name: awx_task
state: started
restart_policy: unless-stopped
image: "{{ awx_task_docker_actual_image }}:{{ awx_version }}"
image: "{{ awx_task_docker_actual_image }}"
links: "{{ awx_task_container_links|list }}"
user: root
hostname: awx