mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Merge branch 'containerization' into devel
* containerization: Updating make targets for fixes to bringing cluster up and svcs Adding Makefile targets for local builds/deployments Moving Openshift work to installer directory to reduce conflicts Support deploying Tower into OpenShift Implementing containerized tower packaging
This commit is contained in:
41
Makefile
41
Makefile
@@ -1,4 +1,4 @@
|
|||||||
PYTHON = python
|
PYTHON ?= python
|
||||||
PYTHON_VERSION = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_version; print(get_python_version())")
|
PYTHON_VERSION = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_version; print(get_python_version())")
|
||||||
SITELIB=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
SITELIB=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
||||||
OFFICIAL ?= no
|
OFFICIAL ?= no
|
||||||
@@ -72,8 +72,10 @@ else
|
|||||||
SETUP_TAR_NAME=$(NAME)-setup-$(VERSION)-$(RELEASE)
|
SETUP_TAR_NAME=$(NAME)-setup-$(VERSION)-$(RELEASE)
|
||||||
SDIST_TAR_NAME=$(NAME)-$(VERSION)-$(RELEASE)
|
SDIST_TAR_NAME=$(NAME)-$(VERSION)-$(RELEASE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SDIST_COMMAND ?= sdist
|
SDIST_COMMAND ?= sdist
|
||||||
SDIST_TAR_FILE=$(SDIST_TAR_NAME).tar.gz
|
SDIST_TAR_FILE ?= $(SDIST_TAR_NAME).tar.gz
|
||||||
|
|
||||||
SETUP_TAR_FILE=$(SETUP_TAR_NAME).tar.gz
|
SETUP_TAR_FILE=$(SETUP_TAR_NAME).tar.gz
|
||||||
SETUP_TAR_LINK=$(NAME)-setup-latest.tar.gz
|
SETUP_TAR_LINK=$(NAME)-setup-latest.tar.gz
|
||||||
SETUP_TAR_CHECKSUM=$(NAME)-setup-CHECKSUM
|
SETUP_TAR_CHECKSUM=$(NAME)-setup-CHECKSUM
|
||||||
@@ -683,6 +685,9 @@ release_clean:
|
|||||||
dist/$(SDIST_TAR_FILE): ui-release
|
dist/$(SDIST_TAR_FILE): ui-release
|
||||||
BUILD="$(BUILD)" $(PYTHON) setup.py $(SDIST_COMMAND)
|
BUILD="$(BUILD)" $(PYTHON) setup.py $(SDIST_COMMAND)
|
||||||
|
|
||||||
|
dist/ansible-tower.tar.gz: ui-release
|
||||||
|
OFFICIAL="yes" $(PYTHON) setup.py sdist
|
||||||
|
|
||||||
sdist: dist/$(SDIST_TAR_FILE)
|
sdist: dist/$(SDIST_TAR_FILE)
|
||||||
@echo "#############################################"
|
@echo "#############################################"
|
||||||
@echo "Artifacts:"
|
@echo "Artifacts:"
|
||||||
@@ -997,3 +1002,35 @@ clean-elk:
|
|||||||
|
|
||||||
psql-container:
|
psql-container:
|
||||||
docker run -it --net tools_default --rm postgres:9.4.1 sh -c 'exec psql -h "postgres" -p "5432" -U postgres'
|
docker run -it --net tools_default --rm postgres:9.4.1 sh -c 'exec psql -h "postgres" -p "5432" -U postgres'
|
||||||
|
|
||||||
|
# Openshift placeholders, these are good for bootstrapping a totally fresh Openshift Node but not for re-running
|
||||||
|
# So you may want to pick and choose the functionality in these targets based on what you are doing
|
||||||
|
openshift-production-build: dist/ansible-tower.tar.gz
|
||||||
|
docker build -t ansible/tower_web -f installer/openshift/Dockerfile .
|
||||||
|
docker build -t ansible/tower_task -f installer/openshift/Dockerfile.celery .
|
||||||
|
|
||||||
|
openshift-production-tag: openshift-production-build
|
||||||
|
docker tag ansible/tower_web:latest 172.30.1.1:5000/tower/tower_web:latest
|
||||||
|
docker tag ansible/tower_task:latest 172.30.1.1:5000/tower/tower_task:latest
|
||||||
|
|
||||||
|
openshift-image-push: openshift-production-tag
|
||||||
|
oc login -u developer && \
|
||||||
|
docker login -u developer -p $(shell oc whoami -t) 172.30.1.1:5000 && \
|
||||||
|
docker push 172.30.1.1:5000/tower/tower_web:latest && \
|
||||||
|
docker push 172.30.1.1:5000/tower/tower_task:latest
|
||||||
|
|
||||||
|
openshift-preconfig:
|
||||||
|
oc login -u developer || true && \
|
||||||
|
oc new-project tower || true && \
|
||||||
|
oc adm policy add-role-to-user admin developer -n tower
|
||||||
|
|
||||||
|
openshift-deploy: openshift-preconfig openshift-image-push
|
||||||
|
oc login -u developer && \
|
||||||
|
oc new-app --template=postgresql-persistent -e MEMORY_LIMIT=512Mi -e NAMESPACE=openshift -e DATABASE_SERVICE_NAME=postgresql -e POSTGRESQL_USER=tower -e POSTGRESQL_PASSWORD=password123 -e POSTGRESQL_DATABASE=tower -e VOLUME_CAPACITY=1Gi -e POSTGRESQL_VERSION=9.5 -n tower && \
|
||||||
|
echo "Waiting for PG to come online" && \
|
||||||
|
sleep 15 && \
|
||||||
|
oc apply -f installer/openshift/config/configmap.yml && \
|
||||||
|
oc apply -f installer/openshift/config/deployment.yml
|
||||||
|
|
||||||
|
openshift-delete:
|
||||||
|
oc delete -f installer/openshift/config/deployment.yml
|
||||||
|
|||||||
54
installer/openshift/Dockerfile
Normal file
54
installer/openshift/Dockerfile
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
# Tower Dependencies Install
|
||||||
|
# TODO: Probably only need Tower dependencies here
|
||||||
|
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/
|
||||||
|
|
||||||
|
# OS Dependencies
|
||||||
|
RUN yum -y install epel-release && 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 git 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
|
||||||
|
RUN pip install virtualenv supervisor
|
||||||
|
WORKDIR /tmp
|
||||||
|
RUN mkdir -p /var/lib/awx/public/static
|
||||||
|
# TODO: Handlers could be stripped of this
|
||||||
|
RUN mkdir -p /var/log/tower
|
||||||
|
RUN mkdir -p /etc/tower
|
||||||
|
RUN head -n 10 /dev/random | sha256sum > /etc/tower/SECRET_KEY
|
||||||
|
RUN VENV_BASE=/var/lib/awx/venv make requirements_ansible && VENV_BASE=/var/lib/awx/venv make requirements_tower
|
||||||
|
COPY dist/ansible-tower-3.2.0.tar.gz /tmp/ansible-tower-3.2.0.tar.gz
|
||||||
|
RUN pip install /tmp/ansible-tower-3.2.0.tar.gz
|
||||||
|
# TODO: Replace this with the actual version
|
||||||
|
RUN echo "3.2.0" > /var/lib/awx/.tower_version
|
||||||
|
ADD installer/openshift/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
ADD installer/openshift/supervisor.conf /supervisor.conf
|
||||||
|
ADD installer/openshift/launch_tower.sh /usr/bin/launch_tower.sh
|
||||||
|
ADD installer/openshift/settings.py /etc/tower/settings.py
|
||||||
|
RUN 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
|
||||||
|
RUN rm -rf /root/.cache
|
||||||
|
RUN chmod g+w /etc/passwd
|
||||||
|
RUN chgrp -Rf root /var/lib/awx && chmod -Rf g+w /var/lib/awx
|
||||||
|
RUN chmod -R 777 /var/log/nginx && chmod -R 777 /var/lib/nginx
|
||||||
|
USER 1000
|
||||||
|
EXPOSE 8052
|
||||||
|
WORKDIR /var/lib/awx
|
||||||
|
ENTRYPOINT ["/tini", "--"]
|
||||||
|
CMD /usr/bin/launch_tower.sh
|
||||||
53
installer/openshift/Dockerfile.celery
Normal file
53
installer/openshift/Dockerfile.celery
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
# Tower Dependencies Install
|
||||||
|
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/
|
||||||
|
|
||||||
|
# OS Dependencies
|
||||||
|
RUN yum -y install epel-release && 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 git curl python-psycopg2 python-pip python-setuptools libselinux-python setools-libs yum-utils sudo acl make postgresql-devel 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
|
||||||
|
RUN pip install virtualenv supervisor
|
||||||
|
WORKDIR /tmp
|
||||||
|
RUN mkdir -p /var/lib/awx
|
||||||
|
# TODO: Handlers could be stripped of this
|
||||||
|
RUN mkdir -p /var/log/tower
|
||||||
|
RUN mkdir -p /etc/tower
|
||||||
|
RUN mkdir -p /var/lib/awx/public/static
|
||||||
|
RUN head -n 10 /dev/random | sha256sum > /etc/tower/SECRET_KEY
|
||||||
|
RUN VENV_BASE=/var/lib/awx/venv make requirements_ansible && VENV_BASE=/var/lib/awx/venv make requirements_tower
|
||||||
|
COPY dist/ansible-tower-3.2.0.tar.gz /tmp/ansible-tower-3.2.0.tar.gz
|
||||||
|
RUN pip install /tmp/ansible-tower-3.2.0.tar.gz
|
||||||
|
# TODO: Replace this with the actual version
|
||||||
|
RUN echo "3.2.0" > /var/lib/awx/.tower_version
|
||||||
|
ADD installer/openshift/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
ADD installer/openshift/supervisor_task.conf /supervisor_task.conf
|
||||||
|
ADD installer/openshift/launch_tower_task.sh /usr/bin/launch_tower_task.sh
|
||||||
|
ADD installer/openshift/settings.py /etc/tower/settings.py
|
||||||
|
RUN 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
|
||||||
|
RUN rm -rf /root/.cache
|
||||||
|
RUN chmod g+w /etc/passwd
|
||||||
|
RUN chgrp -Rf root /var/lib/awx && chmod -Rf g+w /var/lib/awx
|
||||||
|
USER 1000
|
||||||
|
EXPOSE 80 443
|
||||||
|
WORKDIR /var/lib/awx
|
||||||
|
ENTRYPOINT ["/tini", "--"]
|
||||||
|
CMD /usr/bin/launch_tower_task.sh
|
||||||
82
installer/openshift/config/configmap.yml
Normal file
82
installer/openshift/config/configmap.yml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: tower-config
|
||||||
|
namespace: tower
|
||||||
|
data:
|
||||||
|
secret_key: AAABBBCCC
|
||||||
|
tower_settings: |
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
ADMINS = ()
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
#Autoprovisioning should replace this
|
||||||
|
CLUSTER_HOST_ID = socket.gethostname()
|
||||||
|
SYSTEM_UUID = '00000000-0000-0000-0000-000000000000'
|
||||||
|
CELERY_QUEUES += (Queue(CLUSTER_HOST_ID, Exchange(CLUSTER_HOST_ID), routing_key=CLUSTER_HOST_ID),)
|
||||||
|
CELERY_ROUTES['awx.main.tasks.cluster_node_heartbeat'] = {'queue': CLUSTER_HOST_ID, 'routing_key': CLUSTER_HOST_ID}
|
||||||
|
CELERY_ROUTES['awx.main.tasks.purge_old_stdout_files'] = {'queue': CLUSTER_HOST_ID, 'routing_key': CLUSTER_HOST_ID}
|
||||||
|
|
||||||
|
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'
|
||||||
|
AWX_TASK_ENV['HOME'] = '/var/lib/awx'
|
||||||
|
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['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']['awx.main.commands.run_fact_cache_receiver']['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['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'}
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ATOMIC_REQUESTS': True,
|
||||||
|
'ENGINE': 'transaction_hooks.backends.postgresql_psycopg2',
|
||||||
|
'NAME': "tower",
|
||||||
|
'USER': "tower",
|
||||||
|
'PASSWORD': "password123",
|
||||||
|
'HOST': "postgresql",
|
||||||
|
'PORT': "5432",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BROKER_URL = 'amqp://{}:{}@{}:{}/{}'.format(
|
||||||
|
"tower",
|
||||||
|
"abcdefg",
|
||||||
|
"localhost",
|
||||||
|
"5672",
|
||||||
|
"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("localhost", "11211")
|
||||||
|
},
|
||||||
|
}
|
||||||
76
installer/openshift/config/deployment.yml
Normal file
76
installer/openshift/config/deployment.yml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: tower
|
||||||
|
namespace: tower
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: tower-web-deploy
|
||||||
|
service: django
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: tower-web
|
||||||
|
image: 172.30.1.1:5000/tower/tower_web:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 8052
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /etc/tower
|
||||||
|
name: tower-application-config
|
||||||
|
- name: tower-celery
|
||||||
|
image: 172.30.1.1:5000/tower/tower_task:latest
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /etc/tower
|
||||||
|
name: tower-application-config
|
||||||
|
env:
|
||||||
|
- name: DATABASE_USER
|
||||||
|
value: tower
|
||||||
|
- name: DATABASE_NAME
|
||||||
|
value: tower
|
||||||
|
- name: DATABASE_HOST
|
||||||
|
value: postgresql
|
||||||
|
- name: DATABASE_PASSWORD
|
||||||
|
value: password123
|
||||||
|
- name: tower-rabbit
|
||||||
|
image: rabbitmq:3
|
||||||
|
env:
|
||||||
|
- name: RABBITMQ_ERLANG_COOKIE
|
||||||
|
value: secret
|
||||||
|
- name: RABBITMQ_NODENAME
|
||||||
|
value: rabbitmq
|
||||||
|
- name: RABBITMQ_DEFAULT_USER
|
||||||
|
value: tower
|
||||||
|
- name: RABBITMQ_DEFAULT_PASS
|
||||||
|
value: abcdefg
|
||||||
|
- name: RABBITMQ_DEFAULT_VHOST
|
||||||
|
value: tower
|
||||||
|
- name: tower-memcached
|
||||||
|
image: memcached
|
||||||
|
volumes:
|
||||||
|
- name: tower-application-config
|
||||||
|
configMap:
|
||||||
|
name: tower-config
|
||||||
|
items:
|
||||||
|
- key: tower_settings
|
||||||
|
path: settings.py
|
||||||
|
- key: secret_key
|
||||||
|
path: SECRET_KEY
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: tower-web-svc
|
||||||
|
namespace: tower
|
||||||
|
labels:
|
||||||
|
name: tower-web-svc
|
||||||
|
spec:
|
||||||
|
type: "NodePort"
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8052
|
||||||
|
nodePort: 30083
|
||||||
|
selector:
|
||||||
|
name: tower-web-deploy
|
||||||
4
installer/openshift/config/namespace.yml
Normal file
4
installer/openshift/config/namespace.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: tower
|
||||||
5
installer/openshift/inventory
Normal file
5
installer/openshift/inventory
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[primary]
|
||||||
|
localhost
|
||||||
|
|
||||||
|
[all:children]
|
||||||
|
primary
|
||||||
8
installer/openshift/launch_tower.sh
Executable file
8
installer/openshift/launch_tower.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
if [ `id -u` -ge 10000 ]; then
|
||||||
|
echo "awx:x:`id -u`:`id -g`:,,,:/var/lib/awx:/bin/bash" >> /tmp/passwd
|
||||||
|
cat /tmp/passwd > /etc/passwd
|
||||||
|
rm /tmp/passwd
|
||||||
|
fi
|
||||||
|
tower-manage collectstatic --noinput --clear
|
||||||
|
supervisord -c /supervisor.conf
|
||||||
13
installer/openshift/launch_tower_task.sh
Executable file
13
installer/openshift/launch_tower_task.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
if [ `id -u` -ge 10000 ]; 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 postgresql_db -U $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD" all
|
||||||
|
tower-manage migrate --noinput --fake-initial
|
||||||
|
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'root@localhost', 'password')" | tower-manage shell
|
||||||
|
tower-manage create_preload_data
|
||||||
|
tower-manage register_instance --hostname=$(hostname)
|
||||||
|
tower-manage register_queue --queuename=tower --hostnames=$(hostname)
|
||||||
|
supervisord -c /supervisor_task.conf
|
||||||
86
installer/openshift/nginx.conf
Normal file
86
installer/openshift/nginx.conf
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
user awx;
|
||||||
|
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
error_log /dev/stdout warn;
|
||||||
|
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"';
|
||||||
|
|
||||||
|
access_log /dev/stdout main;
|
||||||
|
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
#tcp_nopush on;
|
||||||
|
#gzip on;
|
||||||
|
|
||||||
|
|
||||||
|
upstream uwsgi {
|
||||||
|
server localhost:8050;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream daphne {
|
||||||
|
server localhost: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 ^(.*[^/])$ $1/ permanent;
|
||||||
|
uwsgi_read_timeout 120s;
|
||||||
|
uwsgi_pass uwsgi;
|
||||||
|
include /etc/nginx/uwsgi_params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
80
installer/openshift/settings.py
Normal file
80
installer/openshift/settings.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# AWX settings file
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
ADMINS = ()
|
||||||
|
|
||||||
|
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:80'
|
||||||
|
|
||||||
|
AWX_TASK_ENV['HOME'] = '/var/lib/awx'
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# 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['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']['awx.main.commands.run_fact_cache_receiver']['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']
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ATOMIC_REQUESTS': True,
|
||||||
|
'ENGINE': 'transaction_hooks.backends.postgresql_psycopg2',
|
||||||
|
'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"))
|
||||||
|
},
|
||||||
|
}
|
||||||
51
installer/openshift/supervisor.conf
Normal file
51
installer/openshift/supervisor.conf
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
[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/tower/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
|
||||||
|
2autorestart = 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/tower/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
|
||||||
|
|
||||||
|
[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
|
||||||
77
installer/openshift/supervisor_task.conf
Normal file
77
installer/openshift/supervisor_task.conf
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon = True
|
||||||
|
umask = 022
|
||||||
|
|
||||||
|
[program:celery]
|
||||||
|
# TODO: Needs to be reworked to dynamically use instance group queues
|
||||||
|
command = tower-manage celery worker -l debug --autoscale=4 -Ofair -Q tower_scheduler,tower_broadcast_all,tower,%(host_node_name)s -n celery@localhost
|
||||||
|
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:awx-celeryd-beat]
|
||||||
|
command = /usr/bin/tower-manage celery beat -l debug --pidfile= -s /var/lib/awx/beat.db
|
||||||
|
directory = /var/lib/awx
|
||||||
|
autostart = true
|
||||||
|
autorestart = true
|
||||||
|
stopwaitsecs = 5
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile = /dev/stdout
|
||||||
|
stdout_logfile_maxbytes = 0
|
||||||
|
stderr_logfile = /dev/stderr
|
||||||
|
stderr_logfile_maxbytes = 0
|
||||||
|
|
||||||
|
[program:callback-receiver]
|
||||||
|
command = tower-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:fact-cache-receiver]
|
||||||
|
command = tower-manage run_fact_cache_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 = tower-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,fact-cache-receiver
|
||||||
|
priority=5
|
||||||
|
|
||||||
|
# TODO: Exit Handler
|
||||||
|
|
||||||
|
[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
|
||||||
5
installer/openshift/tower_setup_conf.yml
Normal file
5
installer/openshift/tower_setup_conf.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
admin_password: password
|
||||||
|
database: internal
|
||||||
|
pg_password: CJUWsyKHp5P9AZZqC8Rgk7qFnVVFAPBCJbkzr3bb
|
||||||
|
primary_machine: localhost
|
||||||
|
redis_password: xrQ5uWpfH8ELWyKzfkS8UCRVAjaFruKQq3EvR4a6
|
||||||
Reference in New Issue
Block a user