Move installer roles into roles directory

Signed-off-by: Shane McDonald <me@shanemcd.com>
This commit is contained in:
Shane McDonald
2018-03-22 14:34:03 -04:00
parent ddf000e8e7
commit 84cd933702
32 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# check_docker.yml
---
- name: postgres_data_dir should be defined
assert:
that:
- postgres_data_dir is defined and postgres_data_dir != ''
msg: "Set the value of 'postgres_data_dir' in the inventory file."
when: pg_hostname is not defined or pg_hostname == ''
- name: host_port should be defined
assert:
that:
- host_port is defined and host_port != ''
msg: "Set the value of 'host_port' in the inventory file."

View File

@@ -0,0 +1,48 @@
# check_openshift.yml
---
- name: awx_openshift_project should be defined
assert:
that:
- awx_openshift_project is defined and awx_openshift_project != ''
msg: "Set the value of 'awx_openshift_project' in the inventory file."
- name: openshift_user should be defined
assert:
that:
- openshift_user is defined and openshift_user != ''
msg: "Set the value of 'openshift_user' in the inventory file."
- name: openshift_password or openshift_token should be defined
assert:
that:
- (openshift_password is defined and openshift_password != '') or
(openshift_token is defined and openshift_token != '')
msg: "Set the value of 'openshift_password' or 'openshift_token' in the inventory file."
- name: docker_registry should be defined if not using dockerhub
assert:
that:
- docker_registry is defined and docker_registry != ''
msg: "Set the value of 'docker_registry' in the inventory file."
when: dockerhub_base is not defined
- name: docker_registry_repository should be defined if not using dockerhub
assert:
that:
- docker_registry_repository is defined and docker_registry_repository != ''
msg: "Set the value of 'docker_registry_repository' in the inventory file."
when: dockerhub_base is not defined
- name: docker_registry_username should be defined if not using dockerhub
assert:
that:
- docker_registry_username is defined and docker_registry_username != ''
msg: "Set the value of 'docker_registry_username' in the inventory file."
when: dockerhub_base is not defined
- name: docker_registry_password should be defined
assert:
that:
- docker_registry_password is defined and docker_registry_password != ''
msg: "Set the value of 'docker_registry_password' in the inventory file."
when: dockerhub_base is not defined

View File

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

View File

@@ -0,0 +1,21 @@
FROM centos:7
RUN yum install -y epel-release
RUN yum install -y https://centos7.iuscommunity.org/ius-release.rpm
RUN yum install -y bzip2 \
gcc-c++ \
gettext \
git2u-core \
make \
python \
python-pip
RUN curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
RUN yum install -y nodejs
RUN npm set progress=false
WORKDIR "/awx"
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["make sdist"]

View File

@@ -0,0 +1,52 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
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
OwWvTVGXCPUZTxHiYg==
=msBf
-----END PGP PUBLIC KEY BLOCK-----

View File

@@ -0,0 +1,6 @@
[ansible]
name=Ansible for Enterprise Linux 7 - $basearch
baseurl=https://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ansible-release

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
if [ `id -u` -ge 500 ]; then
echo "awx:x:`id -u`:`id -g`:,,,:/var/lib/awx:/bin/bash" >> /tmp/passwd
cat /tmp/passwd > /etc/passwd
rm /tmp/passwd
fi
awx-manage collectstatic --noinput --clear
supervisord -c /supervisor.conf

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
if [ `id -u` -ge 500 ]; then
echo "awx:x:`id -u`:`id -g`:,,,:/var/lib/awx:/bin/bash" >> /tmp/passwd
cat /tmp/passwd > /etc/passwd
rm /tmp/passwd
fi
ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$DATABASE_HOST port=$DATABASE_PORT" all
ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$MEMCACHED_HOST port=11211" all
ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$RABBITMQ_HOST port=5672" all
ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m postgresql_db --become-user $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD port=$DATABASE_PORT" all
awx-manage migrate --noinput --fake-initial
if [ ! -z "$AWX_ADMIN_USER" ]&&[ ! -z "$AWX_ADMIN_PASSWORD" ]; then
echo "from django.contrib.auth.models import User; User.objects.create_superuser('$AWX_ADMIN_USER', 'root@localhost', '$AWX_ADMIN_PASSWORD')" | awx-manage shell
awx-manage create_preload_data
else
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'root@localhost', 'password')" | awx-manage shell
awx-manage create_preload_data
fi
echo 'from django.conf import settings; x = settings.AWX_TASK_ENV; x["HOME"] = "/var/lib/awx"; settings.AWX_TASK_ENV = x' | awx-manage shell
awx-manage provision_instance --hostname=$(hostname)
awx-manage register_queue --queuename=tower --instance_percent=100
supervisord -c /supervisor_task.conf

View File

@@ -0,0 +1,82 @@
#user awx;
worker_processes 1;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
sendfile on;
#tcp_nopush on;
#gzip on;
upstream uwsgi {
server 127.0.0.1:8050;
}
upstream daphne {
server 127.0.0.1:8051;
}
server {
listen 8052 default_server;
# If you have a domain name, this is where to add it
server_name _;
keepalive_timeout 65;
# HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
add_header Strict-Transport-Security max-age=15768000;
location /static/ {
alias /var/lib/awx/public/static/;
}
location /favicon.ico { alias /var/lib/awx/public/static/favicon.ico; }
location /websocket {
# Pass request to the upstream alias
proxy_pass http://daphne;
# Require http version 1.1 to allow for upgrade requests
proxy_http_version 1.1;
# We want proxy_buffering off for proxying to websockets.
proxy_buffering off;
# http://en.wikipedia.org/wiki/X-Forwarded-For
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# enable this if you use HTTPS:
proxy_set_header X-Forwarded-Proto https;
# pass the Host: header from the client for the sake of redirects
proxy_set_header Host $http_host;
# We've set the Host header, so we don't need Nginx to muddle
# about with redirects
proxy_redirect off;
# Depending on the request value, set the Upgrade and
# connection headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location / {
# Add trailing / if missing
rewrite ^(.*)$http_host(.*[^/])$ $1$http_host$2/ permanent;
uwsgi_read_timeout 120s;
uwsgi_pass uwsgi;
include /etc/nginx/uwsgi_params;
}
}
}

View File

@@ -0,0 +1,111 @@
# AWX settings file
import os
def get_secret():
if os.path.exists("/etc/tower/SECRET_KEY"):
return file('/etc/tower/SECRET_KEY', 'rb').read().strip()
return os.getenv("SECRET_KEY", "privateawx")
ADMINS = ()
STATIC_ROOT = '/var/lib/awx/public/static'
PROJECTS_ROOT = '/var/lib/awx/projects'
JOBOUTPUT_ROOT = '/var/lib/awx/job_status'
SECRET_KEY = get_secret()
ALLOWED_HOSTS = ['*']
INTERNAL_API_URL = 'http://awxweb:8052'
# Container environments don't like chroots
AWX_PROOT_ENABLED = False
CLUSTER_HOST_ID = "awx"
SYSTEM_UUID = '00000000-0000-0000-0000-000000000000'
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False
###############################################################################
# EMAIL SETTINGS
###############################################################################
SERVER_EMAIL = 'root@localhost'
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
EMAIL_SUBJECT_PREFIX = '[AWX] '
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
LOGGING['handlers']['console'] = {
'()': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'simple',
}
LOGGING['loggers']['django.request']['handlers'] = ['console']
LOGGING['loggers']['rest_framework.request']['handlers'] = ['console']
LOGGING['loggers']['awx']['handlers'] = ['console']
LOGGING['loggers']['awx.main.commands.run_callback_receiver']['handlers'] = ['console']
LOGGING['loggers']['awx.main.commands.inventory_import']['handlers'] = ['console']
LOGGING['loggers']['awx.main.tasks']['handlers'] = ['console']
LOGGING['loggers']['awx.main.scheduler']['handlers'] = ['console']
LOGGING['loggers']['django_auth_ldap']['handlers'] = ['console']
LOGGING['loggers']['social']['handlers'] = ['console']
LOGGING['loggers']['system_tracking_migrations']['handlers'] = ['console']
LOGGING['loggers']['rbac_migrations']['handlers'] = ['console']
LOGGING['loggers']['awx.isolated.manager.playbooks']['handlers'] = ['console']
LOGGING['handlers']['callback_receiver'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['fact_receiver'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['task_system'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['tower_warnings'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['rbac_migrations'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['system_tracking_migrations'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['management_playbooks'] = {'class': 'logging.NullHandler'}
DATABASES = {
'default': {
'ATOMIC_REQUESTS': True,
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv("DATABASE_NAME", None),
'USER': os.getenv("DATABASE_USER", None),
'PASSWORD': os.getenv("DATABASE_PASSWORD", None),
'HOST': os.getenv("DATABASE_HOST", None),
'PORT': os.getenv("DATABASE_PORT", None),
}
}
BROKER_URL = 'amqp://{}:{}@{}:{}/{}'.format(
os.getenv("RABBITMQ_USER", None),
os.getenv("RABBITMQ_PASSWORD", None),
os.getenv("RABBITMQ_HOST", None),
os.getenv("RABBITMQ_PORT", "5672"),
os.getenv("RABBITMQ_VHOST", "tower"))
CHANNEL_LAYERS = {
'default': {'BACKEND': 'asgi_amqp.AMQPChannelLayer',
'ROUTING': 'awx.main.routing.channel_routing',
'CONFIG': {'url': BROKER_URL}}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '{}:{}'.format(os.getenv("MEMCACHED_HOST", None),
os.getenv("MEMCACHED_PORT", "11211"))
},
'ephemeral': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
}

View File

@@ -0,0 +1,60 @@
[supervisord]
nodaemon = True
umask = 022
[program:nginx]
command = nginx -g "daemon off;"
autostart = true
autorestart = true
stopwaitsecs = 5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:uwsgi]
command = /var/lib/awx/venv/awx/bin/uwsgi --socket 127.0.0.1:8050 --module=awx.wsgi:application --vacuum --processes=5 --harakiri=120 --no-orphans --master --max-requests=1000 --master-fifo=/var/lib/awx/awxfifo --lazy-apps -b 32768
directory = /var/lib/awx
autostart = true
autorestart = true
stopwaitsecs = 15
stopsignal = INT
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:daphne]
command = /var/lib/awx/venv/awx/bin/daphne -b 127.0.0.1 -p 8051 awx.asgi:channel_layer
directory = /var/lib/awx
autostart = true
autorestart = true
stopwaitsecs = 5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[group:tower-processes]
programs=nginx,uwsgi,daphne
priority=5
# TODO: Exit Handler
[eventlistener:awx-config-watcher]
command=/usr/bin/config-watcher
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
events=TICK_60
priority=0
[unix_http_server]
file=/tmp/supervisor.sock
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

View File

@@ -0,0 +1,62 @@
[supervisord]
nodaemon = True
umask = 022
[program:celery]
command = /var/lib/awx/venv/awx/bin/celery worker -A awx -B -l debug --autoscale=50,4 -Ofair -s /var/lib/awx/beat.db -n celery@%(ENV_HOSTNAME)s
directory = /var/lib/awx
environment = LANGUAGE="en_US.UTF-8",LANG="en_US.UTF-8",LC_ALL="en_US.UTF-8",LC_CTYPE="en_US.UTF-8"
#user = {{ aw_user }}
autostart = true
autorestart = true
stopwaitsecs = 5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:callback-receiver]
command = awx-manage run_callback_receiver
directory = /var/lib/awx
autostart = true
autorestart = true
stopwaitsecs = 5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:channels-worker]
command = awx-manage runworker --only-channels websocket.*
directory = /var/lib/awx
autostart = true
autorestart = true
stopwaitsecs = 5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[group:tower-processes]
programs=celery,callback-receiver,channels-worker
priority=5
# TODO: Exit Handler
[eventlistener:awx-config-watcher]
command=/usr/bin/config-watcher
stderr_logfile=/dev/stdout
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
events=TICK_60
priority=0
[unix_http_server]
file=/tmp/supervisor.sock
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

View File

@@ -0,0 +1,220 @@
---
- name: Get Version from checkout if not provided
shell: "git describe --long --first-parent | sed 's/\\-g.*//' | sed 's/\\-/\\./'"
delegate_to: localhost
register: awx_version_command
when: awx_version is not defined
- name: Set global version if not provided
set_fact:
awx_version: "{{ awx_version_command.stdout }}"
when: awx_version is not defined
- 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
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|default(false)|bool
- name: Set sdist file name
set_fact:
awx_sdist_file: "awx-{{ awx_version }}.tar.gz"
- name: AWX Distribution
debug:
msg: "{{ awx_sdist_file }}"
- name: Stat distribution file
stat:
path: "../dist/{{ awx_sdist_file }}"
delegate_to: localhost
register: sdist
- name: Clean distribution
shell: make clean
args:
chdir: ..
ignore_errors: yes
when: not sdist.stat.exists
delegate_to: localhost
- name: Build sdist builder image
docker_image:
buildargs:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
no_proxy: "{{ no_proxy | default('') }}"
path: "image_build/files"
dockerfile: Dockerfile.sdist
name: awx_sdist_builder
tag: "{{ awx_version }}"
force: true
delegate_to: localhost
when: use_container_for_build|default(true)|bool
- name: Build AWX distribution using container
docker_container:
env:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
no_proxy: "{{ no_proxy | default('') }}"
image: "awx_sdist_builder:{{ awx_version }}"
name: awx_sdist_builder
state: started
detach: false
volumes:
- ../:/awx:Z
delegate_to: localhost
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|default(true)|bool
- 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:
awx_web_image: "{{ awx_web_image|default('awx_web') }}"
- name: Set awx_task image name
set_fact:
awx_task_image: "{{ awx_task_image|default('awx_task') }}"
- 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
copy:
src: nginx.conf
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
- name: Stage config watcher
copy:
src: ../tools/scripts/config-watcher
dest: "{{ docker_base_path }}/config-watcher"
delegate_to: localhost
- name: Stage Makefile
copy:
src: ../Makefile
dest: "{{ docker_base_path }}/Makefile"
delegate_to: localhost
- name: Stage ansible repo
copy:
src: 'ansible.repo'
dest: '{{ docker_base_path }}/ansible.repo'
delegate_to: localhost
- name: Stage ansible repo key
copy:
src: 'RPM-GPG-KEY-ansible-release'
dest: '{{ docker_base_path }}/RPM-GPG-KEY-ansible-release'
delegate_to: localhost
- name: Build base web image
docker_image:
buildargs:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
no_proxy: "{{ no_proxy | default('') }}"
path: "{{ docker_base_path }}"
dockerfile: Dockerfile
name: "{{ awx_web_image }}"
tag: "{{ awx_version }}"
delegate_to: localhost
- name: Build base task image
docker_image:
buildargs:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
no_proxy: "{{ no_proxy | default('') }}"
path: "{{ docker_base_path }}"
dockerfile: Dockerfile.task
name: "{{ awx_task_image }}"
tag: "{{ awx_version }}"
pull: no
delegate_to: localhost
- name: Clean docker base directory
file:
path: "{{ docker_base_path }}"
state: absent
when: cleanup_docker_base|default(True)
delegate_to: localhost

View File

@@ -0,0 +1,66 @@
FROM centos:7
# Do we need this?
#RUN locale-gen en_US.UTF-8
#ENV LANG en_US.UTF-8
#ENV LANGUAGE en_US:en
#ENV LC_ALL en_US.UTF-8
USER root
# Init System
ADD https://github.com/krallin/tini/releases/download/v0.14.0/tini /tini
RUN chmod +x /tini
ADD Makefile /tmp/Makefile
RUN mkdir /tmp/requirements
ADD requirements/requirements_ansible.txt \
requirements/requirements_ansible_uninstall.txt \
requirements/requirements_ansible_git.txt \
requirements/requirements.txt \
requirements/requirements_tower_uninstall.txt \
requirements/requirements_git.txt \
/tmp/requirements/
ADD ansible.repo /etc/yum.repos.d/ansible.repo
ADD config-watcher /usr/bin/config-watcher
ADD RPM-GPG-KEY-ansible-release /etc/pki/rpm-gpg/RPM-GPG-KEY-ansible-release
# OS Dependencies
WORKDIR /tmp
RUN mkdir -p /var/lib/awx/public/static
RUN chgrp -Rf root /var/lib/awx && chmod -Rf g+w /var/lib/awx
RUN yum -y install epel-release && \
yum -y install https://centos7.iuscommunity.org/ius-release.rpm && \
yum -y localinstall http://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm && \
yum -y update && \
yum -y install ansible git2u-core mercurial subversion curl python-psycopg2 python-pip python-setuptools libselinux-python setools-libs yum-utils sudo acl make postgresql-devel nginx python-psutil libxml2-devel libxslt-devel libstdc++.so.6 gcc cyrus-sasl-devel cyrus-sasl openldap-devel libffi-devel python-pip xmlsec1-devel swig krb5-devel xmlsec1-openssl xmlsec1 xmlsec1-openssl-devel libtool-ltdl-devel bubblewrap gcc-c++ python-devel krb5-workstation krb5-libs python-crypto libcurl-devel rsync && \
pip install virtualenv supervisor && \
CFLAGS="-DXMLSEC_NO_SIZE_T" \
VENV_BASE=/var/lib/awx/venv make requirements_ansible && \
VENV_BASE=/var/lib/awx/venv make requirements_awx && \
yum -y remove gcc postgresql-devel libxml2-devel libxslt-devel cyrus-sasl-devel openldap-devel xmlsec1-devel krb5-devel xmlsec1-openssl-devel libtool-ltdl-devel gcc-c++ python-devel && \
yum -y clean all && \
rm -rf /root/.cache
RUN mkdir -p /var/log/tower
RUN mkdir -p /etc/tower
COPY {{ awx_sdist_file }} /tmp/{{ awx_sdist_file }}
RUN OFFICIAL=yes pip install /tmp/{{ awx_sdist_file }}
RUN echo "{{ awx_version }}" > /var/lib/awx/.tower_version
ADD nginx.conf /etc/nginx/nginx.conf
ADD supervisor.conf /supervisor.conf
ADD supervisor_task.conf /supervisor_task.conf
ADD launch_awx.sh /usr/bin/launch_awx.sh
ADD launch_awx_task.sh /usr/bin/launch_awx_task.sh
RUN chmod +rx /usr/bin/launch_awx.sh && chmod +rx /usr/bin/launch_awx_task.sh && chmod +rx /usr/bin/config-watcher
ADD settings.py /etc/tower/settings.py
RUN chmod g+w /etc/passwd
RUN chmod -R 777 /var/log/nginx && chmod -R 777 /var/lib/nginx
VOLUME /var/lib/nginx
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
USER 1000
EXPOSE 8052
WORKDIR /var/lib/awx
ENTRYPOINT ["/tini", "--"]
CMD /usr/bin/launch_awx.sh

View File

@@ -0,0 +1,6 @@
FROM {{ awx_web_image }}:{{ awx_version }}
USER 0
RUN sudo yum -y remove nginx
USER 1000
EXPOSE 8052
CMD /usr/bin/launch_awx_task.sh

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

@@ -0,0 +1,12 @@
---
awx_web_mem_request: 1
awx_web_cpu_request: 500
awx_task_mem_request: 2
awx_task_cpu_request: 1500
awx_rabbitmq_mem_request: 2
awx_rabbitmq_cpu_request: 500
awx_memcached_mem_request: 1
awx_memcached_cpu_request: 500

View File

@@ -0,0 +1,124 @@
---
- name: Set the Kubernetes Context
shell: "kubectl config set-context {{ kubernetes_context }}"
- name: Get Namespace Detail
shell: "kubectl get namespace {{ awx_kubernetes_namespace }}"
register: namespace_details
ignore_errors: yes
- name: Get Postgres Service Detail
shell: "kubectl describe svc awx-postgresql -n {{ awx_kubernetes_namespace }}"
register: postgres_svc_details
ignore_errors: yes
when: "pg_hostname is not defined or pg_hostname == ''"
- name: Create AWX Kubernetes Project
shell: "kubectl create namespace {{ awx_kubernetes_namespace }}"
when: namespace_details.rc != 0
# TODO: This is duplicated in the openshift role, probably needs to be moved to the image_build role
- name: Manage AWX Container Images
block:
- name: Authenticate with Docker registry
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: Wait for Openshift
pause:
seconds: 30
- 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: Wait for the registry to settle
pause:
seconds: 10
- 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 web image path
set_fact:
awx_web_kubernetes_image: "{{ awx_web_image }}:{{ awx_version }}"
when: awx_web_kubernetes_image is not defined
- name: Set full task image path
set_fact:
awx_task_kubernetes_image: "{{ awx_task_image }}:{{ awx_version }}"
when: awx_task_kubernetes_image is not defined
when: dockerhub_base is not defined
- name: Set DockerHub Image Paths
set_fact:
awx_web_kubernetes_image: "{{ dockerhub_base }}/awx_web:{{ dockerhub_version }}"
awx_task_kubernetes_image: "{{ dockerhub_base }}/awx_task:{{ dockerhub_version }}"
when: dockerhub_base is defined
- name: Deploy and Activate Postgres
shell: "helm install --name awx --namespace {{ awx_kubernetes_namespace }} --set postgresUser={{ pg_username }},postgresPassword={{ pg_password }},postgresDatabase={{ pg_database }},persistence.size={{ pg_volume_capacity|default('5')}}Gi stable/postgresql"
when: (pg_hostname is not defined or pg_hostname == '') and (postgres_svc_details is defined and postgres_svc_details.rc != 0)
register: kubernetes_pg_activate
- name: Set postgresql hostname to helm package service
set_fact:
pg_hostname: awx-postgresql
when: pg_hostname is not defined or pg_hostname == ''
- name: Wait for Postgres to activate
pause:
seconds: 60
when: kubernetes_pg_activate|changed
- name: Set kubernetes base path
set_fact:
kubernetes_base_path: "{{ awx_local_base_config_path|default('/tmp') }}/awx-config"
- name: Ensure directory exists
file:
path: "{{ kubernetes_base_path }}"
state: directory
- name: Template Kubernetes AWX etcd2
template:
src: etcd.yml.j2
dest: "{{ kubernetes_base_path }}/etcd.yml"
mode: '0600'
- name: Template Kubernetes AWX Config
template:
src: configmap.yml.j2
dest: "{{ kubernetes_base_path }}/configmap.yml"
mode: '0600'
- name: Template Kubernetes AWX Deployment
template:
src: deployment.yml.j2
dest: "{{ kubernetes_base_path }}/deployment.yml"
mode: '0600'
- name: Apply etcd deployment
shell: "kubectl apply -f {{ kubernetes_base_path }}/etcd.yml"
- name: Apply Configmap
shell: "kubectl apply -f {{ kubernetes_base_path }}/configmap.yml"
- name: Apply Deployment
shell: "kubectl apply -f {{ kubernetes_base_path }}/deployment.yml"

View File

@@ -0,0 +1,102 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: awx-config
namespace: {{ awx_kubernetes_namespace }}
data:
secret_key: {{ awx_secret_key }}
awx_settings: |
import os
import socket
ADMINS = ()
# Container environments don't like chroots
AWX_PROOT_ENABLED = False
# Automatically deprovision pods that go offline
AWX_AUTO_DEPROVISION_INSTANCES = True
SYSTEM_TASK_ABS_CPU = {{ ((awx_task_cpu_request|int / 1000) * 4)|int }}
SYSTEM_TASK_ABS_MEM = {{ ((awx_task_mem_request|int * 1024) / 100)|int }}
#Autoprovisioning should replace this
CLUSTER_HOST_ID = socket.gethostname()
SYSTEM_UUID = '00000000-0000-0000-0000-000000000000'
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
REMOTE_HOST_HEADERS = ['HTTP_X_FORWARDED_FOR']
STATIC_ROOT = '/var/lib/awx/public/static'
PROJECTS_ROOT = '/var/lib/awx/projects'
JOBOUTPUT_ROOT = '/var/lib/awx/job_status'
SECRET_KEY = file('/etc/tower/SECRET_KEY', 'rb').read().strip()
ALLOWED_HOSTS = ['*']
INTERNAL_API_URL = 'http://127.0.0.1:8052'
SERVER_EMAIL = 'root@localhost'
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
EMAIL_SUBJECT_PREFIX = '[AWX] '
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
LOGGING['handlers']['console'] = {
'()': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'simple',
}
LOGGING['loggers']['django.request']['handlers'] = ['console']
LOGGING['loggers']['rest_framework.request']['handlers'] = ['console']
LOGGING['loggers']['awx']['handlers'] = ['console']
LOGGING['loggers']['awx.main.commands.run_callback_receiver']['handlers'] = ['console']
LOGGING['loggers']['awx.main.commands.inventory_import']['handlers'] = ['console']
LOGGING['loggers']['awx.main.tasks']['handlers'] = ['console']
LOGGING['loggers']['awx.main.scheduler']['handlers'] = ['console']
LOGGING['loggers']['django_auth_ldap']['handlers'] = ['console']
LOGGING['loggers']['social']['handlers'] = ['console']
LOGGING['loggers']['system_tracking_migrations']['handlers'] = ['console']
LOGGING['loggers']['rbac_migrations']['handlers'] = ['console']
LOGGING['loggers']['awx.isolated.manager.playbooks']['handlers'] = ['console']
LOGGING['handlers']['callback_receiver'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['fact_receiver'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['task_system'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['tower_warnings'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['rbac_migrations'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['system_tracking_migrations'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['management_playbooks'] = {'class': 'logging.NullHandler'}
DATABASES = {
'default': {
'ATOMIC_REQUESTS': True,
'ENGINE': 'django.db.backends.postgresql',
'NAME': "{{ pg_database }}",
'USER': "{{ pg_username }}",
'PASSWORD': "{{ pg_password }}",
'HOST': "{{ pg_hostname|default('postgresql') }}",
'PORT': "{{ pg_port }}",
}
}
BROKER_URL = 'amqp://{}:{}@{}:{}/{}'.format(
"awx",
"abcdefg",
"localhost",
"5672",
"awx")
CHANNEL_LAYERS = {
'default': {'BACKEND': 'asgi_amqp.AMQPChannelLayer',
'ROUTING': 'awx.main.routing.channel_routing',
'CONFIG': {'url': BROKER_URL}}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '{}:{}'.format("localhost", "11211")
},
'ephemeral': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
}

View File

@@ -0,0 +1,138 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: awx
namespace: {{ awx_kubernetes_namespace }}
spec:
replicas: 1
template:
metadata:
labels:
name: awx-web-deploy
service: django
spec:
containers:
- name: awx-web
image: {{ awx_web_kubernetes_image }}
imagePullPolicy: Always
ports:
- containerPort: 8052
volumeMounts:
- mountPath: /etc/tower
name: awx-application-config
resources:
requests:
memory: "{{ awx_web_mem_request }}Gi"
cpu: "{{ awx_web_cpu_request }}m"
- name: awx-celery
image: {{ awx_task_kubernetes_image }}
imagePullPolicy: Always
volumeMounts:
- mountPath: /etc/tower
name: awx-application-config
env:
- name: DATABASE_USER
value: {{ pg_username }}
- name: DATABASE_NAME
value: {{ pg_database }}
- name: DATABASE_HOST
value: {{ pg_hostname|default('postgresql') }}
- name: DATABASE_PORT
value: "{{ pg_port|default('5432') }}"
- name: DATABASE_PASSWORD
value: {{ pg_password }}
- name: MEMCACHED_HOST
value: {{ memcached_hostname|default('localhost') }}
- name: RABBITMQ_HOST
value: {{ rabbitmq_hostname|default('localhost') }}
- name: AWX_ADMIN_USER
value: {{ default_admin_user|default('admin') }}
- name: AWX_ADMIN_PASSWORD
value: {{ default_admin_password|default('password') }}
resources:
requests:
memory: "{{ awx_task_mem_request }}Gi"
cpu: "{{ awx_task_cpu_request }}m"
- name: awx-rabbit
image: ansible/awx_rabbitmq:{{ rabbitmq_version }}
imagePullPolicy: Always
env:
# For consupmption by rabbitmq-env.conf
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: RABBITMQ_USE_LONGNAME
value: "true"
- name: ERLANG_COOKIE
value: "test"
- name: RABBITMQ_ERLANG_COOKIE
value: "cookiemonster"
- name: RABBITMQ_NODENAME
value: "rabbit@$(MY_POD_IP)"
- name: AUTOCLUSTER_TYPE
value: "etcd"
- name: AUTOCLUSTER_DELAY
value: "60"
- name: ETCD_HOST
value: "etcd"
- name: AUTOCLUSTER_CLEANUP
value: "true"
- name: CLEANUP_WARN_ONLY
value: "false"
- name: CLEANUP_INTERVAL
value: "30"
- name: RABBITMQ_DEFAULT_USER
value: "awx"
- name: RABBITMQ_DEFAULT_PASS
value: "abcdefg"
- name: RABBITMQ_DEFAULT_VHOST
value: "awx"
- name: RABBITMQ_CONFIG_FILE
value: "/etc/rabbitmq/rabbitmq"
resources:
requests:
memory: "{{ awx_rabbitmq_mem_request }}Gi"
cpu: "{{ awx_rabbitmq_cpu_request }}m"
- name: awx-memcached
image: memcached
resources:
requests:
memory: "{{ awx_memcached_mem_request }}Gi"
cpu: "{{ awx_memcached_cpu_request }}m"
volumes:
- name: awx-application-config
configMap:
name: awx-config
items:
- key: awx_settings
path: settings.py
- key: secret_key
path: SECRET_KEY
---
apiVersion: v1
kind: Service
metadata:
name: awx-web-svc
namespace: {{ awx_kubernetes_namespace }}
labels:
name: awx-web-svc
spec:
type: "NodePort"
ports:
- name: http
port: 80
targetPort: 8052
selector:
name: awx-web-deploy
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: awx-web-svc
namespace: {{ awx_kubernetes_namespace }}
spec:
backend:
serviceName: awx-web-svc
servicePort: 80

View File

@@ -0,0 +1,44 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: etcd
namespace: {{ awx_kubernetes_namespace }}
spec:
replicas: 1
template:
metadata:
labels:
name: awx-etcd2
service: etcd
spec:
containers:
- name: etcd
image: elcolio/etcd:latest
ports:
- containerPort: 4001
volumeMounts:
- mountPath: /data
name: datadir
volumes:
- name: datadir
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
name: awx-etcd
name: etcd
namespace: {{ awx_kubernetes_namespace }}
spec:
ports:
- name: etcd
port: 4001
protocol: TCP
targetPort: 4001
selector:
name: awx-etcd2
sessionAffinity: None
type: ClusterIP

View File

@@ -0,0 +1,14 @@
---
- name: Create {{ docker_compose_dir }} directory
file:
path: "{{ docker_compose_dir }}"
state: directory
- name: Create docker-compose.yml file
template:
src: docker-compose.yml.j2
dest: "{{ docker_compose_dir }}/docker-compose.yml"
- name: Start the containers
docker_service:
project_src: "{{ docker_compose_dir }}"

View File

@@ -0,0 +1,7 @@
- import_tasks: set_image.yml
- import_tasks: standalone.yml
when: not (use_docker_compose | default(False) | bool)
- import_tasks: compose.yml
when: use_docker_compose | default(False) | bool

View File

@@ -0,0 +1,83 @@
---
- 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: 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
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
- include_role:
name: image_push
when: docker_registry is defined and dockerhub_base is not 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:
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

View File

@@ -0,0 +1,148 @@
---
- name: Activate postgres container
docker_container:
name: postgres
state: started
restart_policy: unless-stopped
image: postgres:9.6
volumes:
- "{{ postgres_data_dir }}:/var/lib/postgresql/data:Z"
env:
POSTGRES_USER: "{{ pg_username }}"
POSTGRES_PASSWORD: "{{ pg_password }}"
POSTGRES_DB: "{{ pg_database }}"
PGDATA: "/var/lib/postgresql/data/pgdata"
when: pg_hostname is not defined or pg_hostname == ''
register: postgres_container_activate
- name: Activate rabbitmq container
docker_container:
name: rabbitmq
state: started
restart_policy: unless-stopped
image: rabbitmq:3
env:
RABBITMQ_DEFAULT_VHOST: "awx"
register: rabbitmq_container_activate
- name: Activate memcached container
docker_container:
name: memcached
state: started
restart_policy: unless-stopped
image: memcached:alpine
- name: Wait for postgres and rabbitmq to activate
pause:
seconds: 15
when: postgres_container_activate.changed or rabbitmq_container_activate.changed
- name: Set properties without postgres for awx_web
set_fact:
pg_hostname_actual: "{{ pg_hostname }}"
awx_web_container_links:
- rabbitmq
- memcached
when: pg_hostname is defined
- name: Set properties with postgres for awx_web
set_fact:
pg_hostname_actual: postgres
awx_web_container_links:
- rabbitmq
- memcached
- postgres
when: pg_hostname is not defined or pg_hostname == ''
- name: Set properties without postgres for awx_task
set_fact:
pg_hostname_actual: "{{ pg_hostname }}"
awx_task_container_links:
- rabbitmq
- memcached
- awx_web:awxweb
when: pg_hostname is defined
- name: Set properties with postgres for awx_task
set_fact:
pg_hostname_actual: postgres
awx_task_container_links:
- rabbitmq
- memcached
- awx_web:awxweb
- postgres
when: pg_hostname is not defined or pg_hostname == ''
- name: Activate AWX Web Container
docker_container:
name: awx_web
state: started
restart_policy: unless-stopped
image: "{{ awx_web_docker_actual_image }}"
volumes: >
{{
[project_data_dir + ':/var/lib/awx/projects:rw'] if project_data_dir is defined else []
+ [ca_trust_dir + ':/etc/pki/ca-trust:ro'] if ca_trust_dir is defined else []
}}
user: root
ports:
- "{{ host_port }}:8052"
links: "{{ awx_web_container_links|list }}"
hostname: awxweb
dns_search_domains: "{{ awx_container_search_domains.split(',') if awx_container_search_domains is defined else omit }}"
dns_servers: "{{ awx_alternate_dns_servers.split(',') if awx_alternate_dns_servers is defined else omit }}"
env:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
no_proxy: "{{ no_proxy | default('') }}"
SECRET_KEY: "{{ awx_secret_key }}"
DATABASE_NAME: "{{ pg_database }}"
DATABASE_USER: "{{ pg_username }}"
DATABASE_PASSWORD: "{{ pg_password }}"
DATABASE_PORT: "{{ pg_port }}"
DATABASE_HOST: "{{ pg_hostname_actual }}"
RABBITMQ_USER: "guest"
RABBITMQ_PASSWORD: "guest"
RABBITMQ_HOST: "rabbitmq"
RABBITMQ_PORT: "5672"
RABBITMQ_VHOST: "awx"
MEMCACHED_HOST: "memcached"
MEMCACHED_PORT: "11211"
AWX_ADMIN_USER: "{{ default_admin_user|default('admin') }}"
AWX_ADMIN_PASSWORD: "{{ default_admin_password|default('password') }}"
- name: Activate AWX Task Container
docker_container:
name: awx_task
state: started
restart_policy: unless-stopped
image: "{{ awx_task_docker_actual_image }}"
volumes: >
{{
[project_data_dir + ':/var/lib/awx/projects:rw'] if project_data_dir is defined else []
+ [ca_trust_dir + ':/etc/pki/ca-trust:ro'] if ca_trust_dir is defined else []
}}
links: "{{ awx_task_container_links|list }}"
user: root
hostname: awx
dns_search_domains: "{{ awx_container_search_domains.split(',') if awx_container_search_domains is defined else omit }}"
dns_servers: "{{ awx_alternate_dns_servers.split(',') if awx_alternate_dns_servers is defined else omit }}"
env:
http_proxy: "{{ http_proxy | default('') }}"
https_proxy: "{{ https_proxy | default('') }}"
no_proxy: "{{ no_proxy | default('') }}"
SECRET_KEY: "{{ awx_secret_key }}"
DATABASE_NAME: "{{ pg_database }}"
DATABASE_USER: "{{ pg_username }}"
DATABASE_PASSWORD: "{{ pg_password }}"
DATABASE_HOST: "{{ pg_hostname_actual }}"
DATABASE_PORT: "{{ pg_port }}"
RABBITMQ_USER: "guest"
RABBITMQ_PASSWORD: "guest"
RABBITMQ_HOST: "rabbitmq"
RABBITMQ_PORT: "5672"
RABBITMQ_VHOST: "awx"
MEMCACHED_HOST: "memcached"
MEMCACHED_PORT: "11211"
AWX_ADMIN_USER: "{{ default_admin_user|default('admin') }}"
AWX_ADMIN_PASSWORD: "{{ default_admin_password|default('password') }}"

View File

@@ -0,0 +1,145 @@
#jinja2: lstrip_blocks: True
version: '2'
services:
web:
image: {{ awx_web_docker_actual_image }}
depends_on:
- rabbitmq
- memcached
{% if pg_hostname is not defined %}
- postgres
{% endif %}
ports:
- "{{ host_port }}:8052"
hostname: awxweb
user: root
restart: unless-stopped
{% if (project_data_dir is defined) or (ca_trust_dir is defined) %}
volumes:
{% endif %}
{% if project_data_dir is defined %}
- "{{ project_data_dir +':/var/lib/awx/projects:rw' }}"
{% endif %}
{% if ca_trust_dir is defined %}
- "{{ ca_trust_dir +':/etc/pki/ca-trust:ro' }}"
{% endif %}
{% if (awx_container_search_domains is defined) and (',' in awx_container_search_domains) %}
{% set awx_container_search_domains_list = awx_container_search_domains.split(',') %}
dns_search:
{% for awx_container_search_domain in awx_container_search_domains_list %}
- {{ awx_container_search_domain }}
{% endfor %}
{% elif awx_container_search_domains is defined %}
dns_search: "{{ awx_container_search_domains }}"
{% endif %}
{% if (awx_alternate_dns_servers is defined) and (',' in awx_alternate_dns_servers) %}
{% set awx_alternate_dns_servers_list = awx_alternate_dns_servers.split(',') %}
dns:
{% for awx_alternate_dns_server in awx_alternate_dns_servers_list %}
- {{ awx_alternate_dns_server }}
{% endfor %}
{% elif awx_alternate_dns_servers is defined -%}
dns: "{{ awx_alternate_dns_servers }}"
{% endif %}
environment:
http_proxy: {{ http_proxy | default('') }}
https_proxy: {{ https_proxy | default('') }}
no_proxy: {{ no_proxy | default('') }}
SECRET_KEY: {{ awx_secret_key }}
DATABASE_NAME: {{ pg_database }}
DATABASE_USER: {{ pg_username }}
DATABASE_PASSWORD: {{ pg_password }}
DATABASE_PORT: {{ pg_port }}
DATABASE_HOST: {{ pg_hostname|default("postgres") }}
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
RABBITMQ_VHOST: awx
MEMCACHED_HOST: memcached
MEMCACHED_PORT: 11211
AWX_ADMIN_USER: {{ default_admin_user|default('admin') }}
AWX_ADMIN_PASSWORD: {{ default_admin_password|default('password') }}
task:
image: {{ awx_task_docker_actual_image }}
depends_on:
- rabbitmq
- memcached
- web
{% if pg_hostname is not defined %}
- postgres
{% endif %}
hostname: awx
user: root
restart: unless-stopped
{% if (project_data_dir is defined) or (ca_trust_dir is defined) %}
volumes:
{% endif %}
{% if project_data_dir is defined %}
- "{{ project_data_dir +':/var/lib/awx/projects:rw' }}"
{% endif %}
{% if ca_trust_dir is defined %}
- "{{ ca_trust_dir +':/etc/pki/ca-trust:ro' }}"
{% endif %}
{% if (awx_container_search_domains is defined) and (',' in awx_container_search_domains) %}
{% set awx_container_search_domains_list = awx_container_search_domains.split(',') %}
dns_search:
{% for awx_container_search_domain in awx_container_search_domains_list %}
- {{ awx_container_search_domain }}
{% endfor %}
{% elif awx_container_search_domains is defined %}
dns_search: "{{ awx_container_search_domains }}"
{% endif %}
{% if (awx_alternate_dns_servers is defined) and (',' in awx_alternate_dns_servers) %}
{% set awx_alternate_dns_servers_list = awx_alternate_dns_servers.split(',') %}
dns:
{% for awx_alternate_dns_server in awx_alternate_dns_servers_list %}
- {{ awx_alternate_dns_server }}
{% endfor %}
{% elif awx_alternate_dns_servers is defined -%}
dns: "{{ awx_alternate_dns_servers }}"
{% endif %}
environment:
http_proxy: {{ http_proxy | default('') }}
https_proxy: {{ https_proxy | default('') }}
no_proxy: {{ no_proxy | default('') }}
SECRET_KEY: {{ awx_secret_key }}
DATABASE_NAME: {{ pg_database }}
DATABASE_USER: {{ pg_username }}
DATABASE_PASSWORD: {{ pg_password }}
DATABASE_HOST: {{ pg_hostname|default("postgres") }}
DATABASE_PORT: {{ pg_port }}
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
RABBITMQ_HOST: rabbitmq
RABBITMQ_PORT: 5672
RABBITMQ_VHOST: awx
MEMCACHED_HOST: memcached
MEMCACHED_PORT: 11211
AWX_ADMIN_USER: {{ default_admin_user|default('admin') }}
AWX_ADMIN_PASSWORD: {{ default_admin_password|default('password') }}
rabbitmq:
image: rabbitmq:3
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_VHOST: awx
memcached:
image: memcached:alpine
restart: unless-stopped
{% if pg_hostname is not defined %}
postgres:
image: postgres:9.6
restart: unless-stopped
volumes:
- {{ postgres_data_dir }}:/var/lib/postgresql/data:Z
environment:
POSTGRES_USER: {{ pg_username }}
POSTGRES_PASSWORD: {{ pg_password }}
POSTGRES_DB: {{ pg_database }}
PGDATA: /var/lib/postgresql/data/pgdata
{% endif %}

View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: tower

View File

@@ -0,0 +1,12 @@
---
awx_web_mem_request: 1
awx_web_cpu_request: 500
awx_task_mem_request: 2
awx_task_cpu_request: 1500
awx_rabbitmq_mem_request: 2
awx_rabbitmq_cpu_request: 500
awx_memcached_mem_request: 1
awx_memcached_cpu_request: 500

View File

@@ -0,0 +1,145 @@
---
- name: Authenticate with OpenShift via user and password
shell: "oc login {{ openshift_host }} -u {{ openshift_user }} -p {{ openshift_password }}"
when:
- openshift_user is defined
- openshift_password is defined
- openshift_token is not defined
- name: Authenticate with OpenShift via token
shell: "oc login {{ openshift_host }} --token {{ openshift_token }}"
when: openshift_token is defined
- name: Get Project Detail
shell: "oc get project {{ awx_openshift_project }}"
register: project_details
ignore_errors: yes
- name: Get Postgres Service Detail
shell: "oc describe svc postgresql -n {{ awx_openshift_project }}"
register: postgres_svc_details
ignore_errors: yes
when: "pg_hostname is not defined or pg_hostname == ''"
- name: Create AWX Openshift Project
shell: "oc new-project {{ awx_openshift_project }}"
when: project_details.rc != 0
# This might could/should be optional based on certain circumstances
- name: Mark Openshift User as Admin
shell: "oc adm policy add-role-to-user admin {{ openshift_user }} -n {{ awx_openshift_project }}"
# TODO: This is duplicated in the kubernetes role, probably needs to be moved to the image_build role
- name: Manage AWX Container Images
block:
- name: Get docker registry password from oc if needed
block:
- name: Set docker registry password
shell: oc whoami -t
register: docker_registry_password_shell
- name: Set docker registry password
set_fact:
docker_registry_password: "{{ docker_registry_password_shell.stdout }}"
when: docker_registry_password is not defined
- name: Authenticate with Docker registry
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: Wait for Openshift
pause:
seconds: 30
- 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: Wait for the registry to settle
pause:
seconds: 10
- 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
# Note this is the one bit that is Openshift specific
- name: Enable image stream lookups for awx images
shell: "oc set image-lookup --all -n {{ awx_openshift_project }}"
- name: Set full web image path
set_fact:
awx_web_openshift_image: "{{ awx_web_image }}:{{ awx_version }}"
when: awx_web_openshift_image is not defined
- name: Set full task image path
set_fact:
awx_task_openshift_image: "{{ awx_task_image }}:{{ awx_version }}"
when: awx_task_openshift_image is not defined
when: dockerhub_base is not defined
- name: Set DockerHub Image Paths
set_fact:
awx_web_openshift_image: "{{ dockerhub_base }}/awx_web:{{ dockerhub_version }}"
awx_task_openshift_image: "{{ dockerhub_base }}/awx_task:{{ dockerhub_version }}"
when: dockerhub_base is defined
- name: Deploy and Activate Postgres
shell: "oc new-app --template=postgresql-persistent -e MEMORY_LIMIT={{ pg_memory_limit|default('512') }}Mi -e NAMESPACE=openshift -e DATABASE_SERVICE_NAME=postgresql -e POSTGRESQL_USER={{ pg_username }} -e POSTGRESQL_PASSWORD={{ pg_password }} -e POSTGRESQL_DATABASE={{ pg_database }} -e VOLUME_CAPACITY={{ pg_volume_capacity|default('5')}}Gi -e POSTGRESQL_VERSION=9.5 -n {{ awx_openshift_project }}"
when: (pg_hostname is not defined or pg_hostname == '') and (postgres_svc_details is defined and postgres_svc_details.rc != 0)
register: openshift_pg_activate
- name: Wait for Postgres to activate
pause:
seconds: 15
when: openshift_pg_activate|changed
- name: Set openshift base path
set_fact:
openshift_base_path: "{{ awx_local_base_config_path|default('/tmp') }}/awx-config"
- name: Ensure directory exists
file:
path: "{{ openshift_base_path }}"
state: directory
- name: Template Openshift AWX Config
template:
src: configmap.yml.j2
dest: "{{ openshift_base_path }}/configmap.yml"
mode: '0600'
- name: Template Openshift AWX Deployment
template:
src: deployment.yml.j2
dest: "{{ openshift_base_path }}/deployment.yml"
mode: '0600'
- name: Template Openshift AWX etcd2
template:
src: etcd.yml.j2
dest: "{{ openshift_base_path }}/etcd.yml"
mode: '0600'
- name: Apply etcd deployment
shell: "oc apply -f {{ openshift_base_path }}/etcd.yml"
- name: Apply Configmap
shell: "oc apply -f {{ openshift_base_path }}/configmap.yml"
- name: Apply Deployment
shell: "oc apply -f {{ openshift_base_path }}/deployment.yml"

View File

@@ -0,0 +1,102 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: awx-config
namespace: {{ awx_openshift_project }}
data:
secret_key: {{ awx_secret_key }}
awx_settings: |
import os
import socket
ADMINS = ()
# Container environments don't like chroots
AWX_PROOT_ENABLED = False
# Automatically deprovision pods that go offline
AWX_AUTO_DEPROVISION_INSTANCES = True
SYSTEM_TASK_ABS_CPU = {{ ((awx_task_cpu_request|int / 1000) * 4)|int }}
SYSTEM_TASK_ABS_MEM = {{ ((awx_task_mem_request|int * 1024) / 100)|int }}
#Autoprovisioning should replace this
CLUSTER_HOST_ID = socket.gethostname()
SYSTEM_UUID = '00000000-0000-0000-0000-000000000000'
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
REMOTE_HOST_HEADERS = ['HTTP_X_FORWARDED_FOR']
STATIC_ROOT = '/var/lib/awx/public/static'
PROJECTS_ROOT = '/var/lib/awx/projects'
JOBOUTPUT_ROOT = '/var/lib/awx/job_status'
SECRET_KEY = file('/etc/tower/SECRET_KEY', 'rb').read().strip()
ALLOWED_HOSTS = ['*']
INTERNAL_API_URL = 'http://127.0.0.1:8052'
SERVER_EMAIL = 'root@localhost'
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
EMAIL_SUBJECT_PREFIX = '[AWX] '
EMAIL_HOST = 'localhost'
EMAIL_PORT = 25
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
LOGGING['handlers']['console'] = {
'()': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'simple',
}
LOGGING['loggers']['django.request']['handlers'] = ['console']
LOGGING['loggers']['rest_framework.request']['handlers'] = ['console']
LOGGING['loggers']['awx']['handlers'] = ['console']
LOGGING['loggers']['awx.main.commands.run_callback_receiver']['handlers'] = ['console']
LOGGING['loggers']['awx.main.commands.inventory_import']['handlers'] = ['console']
LOGGING['loggers']['awx.main.tasks']['handlers'] = ['console']
LOGGING['loggers']['awx.main.scheduler']['handlers'] = ['console']
LOGGING['loggers']['django_auth_ldap']['handlers'] = ['console']
LOGGING['loggers']['social']['handlers'] = ['console']
LOGGING['loggers']['system_tracking_migrations']['handlers'] = ['console']
LOGGING['loggers']['rbac_migrations']['handlers'] = ['console']
LOGGING['loggers']['awx.isolated.manager.playbooks']['handlers'] = ['console']
LOGGING['handlers']['callback_receiver'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['fact_receiver'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['task_system'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['tower_warnings'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['rbac_migrations'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['system_tracking_migrations'] = {'class': 'logging.NullHandler'}
LOGGING['handlers']['management_playbooks'] = {'class': 'logging.NullHandler'}
DATABASES = {
'default': {
'ATOMIC_REQUESTS': True,
'ENGINE': 'django.db.backends.postgresql',
'NAME': "{{ pg_database }}",
'USER': "{{ pg_username }}",
'PASSWORD': "{{ pg_password }}",
'HOST': "{{ pg_hostname|default('postgresql') }}",
'PORT': "{{ pg_port }}",
}
}
BROKER_URL = 'amqp://{}:{}@{}:{}/{}'.format(
"awx",
"abcdefg",
"localhost",
"5672",
"awx")
CHANNEL_LAYERS = {
'default': {'BACKEND': 'asgi_amqp.AMQPChannelLayer',
'ROUTING': 'awx.main.routing.channel_routing',
'CONFIG': {'url': BROKER_URL}}
}
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '{}:{}'.format("localhost", "11211")
},
'ephemeral': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
},
}

View File

@@ -0,0 +1,159 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: awx
namespace: {{ awx_openshift_project }}
spec:
replicas: 1
template:
metadata:
labels:
name: awx-web-deploy
service: django
spec:
containers:
- name: awx-web
image: {{ awx_web_openshift_image }}
imagePullPolicy: Always
ports:
- containerPort: 8052
volumeMounts:
- mountPath: /etc/tower
name: awx-application-config
resources:
requests:
memory: "{{ awx_web_mem_request }}Gi"
cpu: "{{ awx_web_cpu_request }}m"
- name: awx-celery
image: {{ awx_task_openshift_image }}
imagePullPolicy: Always
volumeMounts:
- mountPath: /etc/tower
name: awx-application-config
env:
- name: DATABASE_USER
value: {{ pg_username }}
- name: DATABASE_NAME
value: {{ pg_database }}
- name: DATABASE_HOST
value: {{ pg_hostname|default('postgresql') }}
- name: DATABASE_PORT
value: "{{ pg_port|default('5432') }}"
- name: DATABASE_PASSWORD
value: {{ pg_password }}
- name: MEMCACHED_HOST
value: {{ memcached_hostname|default('localhost') }}
- name: RABBITMQ_HOST
value: {{ rabbitmq_hostname|default('localhost') }}
- name: AWX_ADMIN_USER
value: {{ default_admin_user|default('admin') }}
- name: AWX_ADMIN_PASSWORD
value: {{ default_admin_password|default('password') }}
resources:
requests:
memory: "{{ awx_task_mem_request }}Gi"
cpu: "{{ awx_task_cpu_request }}m"
- name: awx-rabbit
image: ansible/awx_rabbitmq:{{ rabbitmq_version }}
imagePullPolicy: Always
env:
# For consupmption by rabbitmq-env.conf
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: RABBITMQ_USE_LONGNAME
value: "true"
- name: RABBITMQ_ERLANG_COOKIE
value: "cookiemonster"
- name: RABBITMQ_NODENAME
value: "rabbit@$(MY_POD_IP)"
- name: AUTOCLUSTER_TYPE
value: "etcd"
- name: AUTOCLUSTER_DELAY
value: "60"
- name: ETCD_HOST
value: "etcd"
- name: AUTOCLUSTER_CLEANUP
value: "true"
- name: CLEANUP_WARN_ONLY
value: "false"
- name: CLEANUP_INTERVAL
value: "30"
- name: RABBITMQ_DEFAULT_USER
value: "awx"
- name: RABBITMQ_DEFAULT_PASS
value: "abcdefg"
- name: RABBITMQ_DEFAULT_VHOST
value: "awx"
- name: RABBITMQ_CONFIG_FILE
value: "/etc/rabbitmq/rabbitmq"
resources:
requests:
memory: "{{ awx_rabbitmq_mem_request }}Gi"
cpu: "{{ awx_rabbitmq_cpu_request }}m"
- name: awx-memcached
image: memcached
resources:
requests:
memory: "{{ awx_memcached_mem_request }}Gi"
cpu: "{{ awx_memcached_cpu_request }}m"
volumes:
- name: awx-application-config
configMap:
name: awx-config
items:
- key: awx_settings
path: settings.py
- key: secret_key
path: SECRET_KEY
---
apiVersion: v1
kind: Service
metadata:
name: awx-web-svc
namespace: {{ awx_openshift_project }}
labels:
name: awx-web-svc
spec:
type: "NodePort"
ports:
- name: http
port: 8052
selector:
name: awx-web-deploy
---
---
apiVersion: v1
kind: Service
metadata:
name: awx-rmq-mgmt
namespace: {{ awx_openshift_project }}
labels:
name: awx-rmq-mgmt
spec:
type: ClusterIP
ports:
- name: rmqmgmt
port: 15672
targetPort: 15672
selector:
name: awx-web-deploy
---
apiVersion: v1
kind: Route
metadata:
name: awx-web-svc
namespace: {{ awx_openshift_project }}
spec:
port:
targetPort: http
tls:
insecureEdgeTerminationPolicy: Allow
termination: edge
to:
kind: Service
name: awx-web-svc
weight: 100
wildcardPolicy: None

View File

@@ -0,0 +1,44 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: etcd
namespace: {{ awx_openshift_project }}
spec:
replicas: 1
template:
metadata:
labels:
name: awx-etcd2
service: etcd
spec:
containers:
- name: etcd
image: elcolio/etcd:latest
ports:
- containerPort: 4001
volumeMounts:
- mountPath: /data
name: datadir
volumes:
- name: datadir
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
name: awx-etcd
name: etcd
namespace: {{ awx_openshift_project }}
spec:
ports:
- name: etcd
port: 4001
protocol: TCP
targetPort: 4001
selector:
name: awx-etcd2
sessionAffinity: None
type: ClusterIP