2017-08-16 04:42:18 +03:00
---
- name : Set global version if not provided
set_fact :
2018-10-03 22:44:26 +03:00
awx_version : "{{ lookup('file', playbook_dir + '/../VERSION') }}"
2017-08-16 04:42:18 +03:00
when : awx_version is not defined
2017-08-30 20:40:18 +03:00
- name : Verify awx-logos directory exists for official install
stat :
path : "../../awx-logos"
delegate_to : localhost
register : logosdir
failed_when : logosdir.stat.isdir is not defined or not logosdir.stat.isdir
2017-09-26 04:52:23 +03:00
when : awx_official|default(false)|bool
2017-08-30 20:40:18 +03:00
- name : Copy logos for inclusion in sdist
2017-09-23 00:06:24 +03:00
copy :
2017-08-30 20:40:18 +03:00
src : "../../awx-logos/awx/ui/client/assets"
dest : "../awx/ui/client/"
delegate_to : localhost
2017-09-26 04:52:23 +03:00
when : awx_official|default(false)|bool
2017-08-30 20:40:18 +03:00
2017-08-16 04:42:18 +03:00
- name : Set sdist file name
set_fact :
awx_sdist_file : "awx-{{ awx_version }}.tar.gz"
- name : AWX Distribution
debug :
msg : "{{ awx_sdist_file }}"
2017-09-01 05:21:25 +03:00
- name : Stat distribution file
stat :
path : "../dist/{{ awx_sdist_file }}"
delegate_to : localhost
register : sdist
2017-08-30 20:40:18 +03:00
- name : Clean distribution
shell : make clean
args :
chdir : ..
2017-09-01 05:21:25 +03:00
ignore_errors : yes
when : not sdist.stat.exists
2017-08-30 20:40:18 +03:00
delegate_to : localhost
2017-09-11 01:54:21 +03:00
- name : Build sdist builder image
docker_image :
2017-09-13 14:56:58 +03:00
buildargs :
http_proxy : "{{ http_proxy | default('') }}"
https_proxy : "{{ https_proxy | default('') }}"
no_proxy : "{{ no_proxy | default('') }}"
2018-03-23 18:53:31 +03:00
path : "{{ role_path }}/files"
2017-09-11 01:54:21 +03:00
dockerfile : Dockerfile.sdist
name : awx_sdist_builder
tag : "{{ awx_version }}"
force : true
2017-09-12 19:38:48 +03:00
delegate_to : localhost
2017-09-26 04:52:23 +03:00
when : use_container_for_build|default(true)|bool
2017-09-11 01:54:21 +03:00
2017-09-16 06:08:57 +03:00
- name : Build AWX distribution using container
2017-09-11 01:54:21 +03:00
docker_container :
2017-09-13 14:56:58 +03:00
env :
http_proxy : "{{ http_proxy | default('') }}"
https_proxy : "{{ https_proxy | default('') }}"
no_proxy : "{{ no_proxy | default('') }}"
2017-09-11 01:54:21 +03:00
image : "awx_sdist_builder:{{ awx_version }}"
name : awx_sdist_builder
state : started
detach : false
volumes :
2017-09-11 22:05:29 +03:00
- ../:/awx:Z
2017-09-12 19:38:48 +03:00
delegate_to : localhost
2017-09-26 04:52:23 +03:00
when : use_container_for_build|default(true)|bool
2017-09-16 06:08:57 +03:00
- name : Build AWX distribution locally
shell : make sdist
args :
chdir : ..
delegate_to : localhost
2017-09-26 04:52:23 +03:00
when : not use_container_for_build|default(true)|bool
2017-08-16 04:42:18 +03:00
- name : Set docker build base path
set_fact :
docker_base_path : "{{ awx_local_base_config_path|default('/tmp') }}/docker-image"
- name : Set awx_web image name
set_fact :
2018-04-17 00:56:06 +03:00
web_image : "{{ web_image|default('awx_web') }}"
2017-08-16 04:42:18 +03:00
- name : Set awx_task image name
set_fact :
2018-04-17 00:56:06 +03:00
task_image : "{{ task_image|default('awx_task') }}"
2017-08-16 04:42:18 +03:00
- name : Ensure directory exists
file :
path : "{{ docker_base_path }}"
state : directory
delegate_to : localhost
- name : Stage sdist
copy :
src : "../dist/{{ awx_sdist_file }}"
dest : "{{ docker_base_path }}/{{ awx_sdist_file }}"
delegate_to : localhost
- name : Template web Dockerfile
template :
src : Dockerfile.j2
dest : "{{ docker_base_path }}/Dockerfile"
delegate_to : localhost
- name : Template task Dockerfile
template :
src : Dockerfile.task.j2
dest : "{{ docker_base_path }}/Dockerfile.task"
delegate_to : localhost
- name : Stage launch_awx
copy :
src : launch_awx.sh
dest : "{{ docker_base_path }}/launch_awx.sh"
mode : '0700'
delegate_to : localhost
- name : Stage launch_awx_task
copy :
src : launch_awx_task.sh
dest : "{{ docker_base_path }}/launch_awx_task.sh"
mode : '0700'
delegate_to : localhost
- name : Stage nginx.conf
2018-06-05 18:16:08 +03:00
template :
2019-02-28 16:06:59 +03:00
src : nginx.conf.j2
2017-08-16 04:42:18 +03:00
dest : "{{ docker_base_path }}/nginx.conf"
delegate_to : localhost
- name : Stage supervisor.conf
copy :
src : supervisor.conf
dest : "{{ docker_base_path }}/supervisor.conf"
delegate_to : localhost
- name : Stage supervisor_task.conf
copy :
src : supervisor_task.conf
dest : "{{ docker_base_path }}/supervisor_task.conf"
delegate_to : localhost
- name : Stage settings.py
copy :
src : settings.py
dest : "{{ docker_base_path }}/settings.py"
delegate_to : localhost
- name : Stage requirements
copy :
src : ../requirements/
dest : "{{ docker_base_path }}/requirements"
delegate_to : localhost
2017-10-12 21:14:30 +03:00
- name : Stage config watcher
copy :
src : ../tools/scripts/config-watcher
dest : "{{ docker_base_path }}/config-watcher"
delegate_to : localhost
2017-08-16 04:42:18 +03:00
- name : Stage Makefile
copy :
src : ../Makefile
dest : "{{ docker_base_path }}/Makefile"
delegate_to : localhost
2018-02-07 01:57:59 +03:00
- name : Stage ansible repo
2017-09-16 06:31:10 +03:00
copy :
src : 'ansible.repo'
dest : '{{ docker_base_path }}/ansible.repo'
delegate_to : localhost
2018-02-07 01:57:59 +03:00
- name : Stage ansible repo key
2017-09-16 06:31:10 +03:00
copy :
src : 'RPM-GPG-KEY-ansible-release'
dest : '{{ docker_base_path }}/RPM-GPG-KEY-ansible-release'
delegate_to : localhost
2017-08-16 04:42:18 +03:00
- name : Build base web image
docker_image :
2017-09-13 14:56:58 +03:00
buildargs :
http_proxy : "{{ http_proxy | default('') }}"
https_proxy : "{{ https_proxy | default('') }}"
no_proxy : "{{ no_proxy | default('') }}"
2017-08-16 04:42:18 +03:00
path : "{{ docker_base_path }}"
dockerfile : Dockerfile
2018-04-17 00:56:06 +03:00
name : "{{ web_image }}"
2017-08-16 04:42:18 +03:00
tag : "{{ awx_version }}"
2019-01-15 01:33:01 +03:00
force : yes
2017-08-16 04:42:18 +03:00
delegate_to : localhost
- name : Build base task image
docker_image :
2017-09-13 14:56:58 +03:00
buildargs :
http_proxy : "{{ http_proxy | default('') }}"
https_proxy : "{{ https_proxy | default('') }}"
no_proxy : "{{ no_proxy | default('') }}"
2017-08-16 04:42:18 +03:00
path : "{{ docker_base_path }}"
dockerfile : Dockerfile.task
2018-04-17 00:56:06 +03:00
name : "{{ task_image }}"
2017-08-16 04:42:18 +03:00
tag : "{{ awx_version }}"
pull : no
2019-01-15 01:33:01 +03:00
force : yes
2017-08-16 04:42:18 +03:00
delegate_to : localhost
2017-09-08 00:21:28 +03:00
2018-04-17 00:56:06 +03:00
- name : Tag task and web images as latest
command : "docker tag {{ item }}:{{ awx_version }} {{ item }}:latest"
2018-04-20 07:07:25 +03:00
delegate_to : localhost
2018-04-17 00:56:06 +03:00
with_items :
- "{{ task_image }}"
- "{{ web_image }}"
2017-08-16 04:42:18 +03:00
- name : Clean docker base directory
file :
path : "{{ docker_base_path }}"
state : absent
2018-07-25 20:10:31 +03:00
when : cleanup_docker_base|default(True)|bool
2017-09-01 05:21:25 +03:00
delegate_to : localhost