mirror of
https://github.com/EpicMorg/docker-scripts.git
synced 2025-01-26 13:37:57 +03:00
ansible image generator (wip)
ready to jira9
This commit is contained in:
parent
ff09bc5973
commit
7873dbf295
16
bin/ansible/ansible.cfg
Normal file
16
bin/ansible/ansible.cfg
Normal file
@ -0,0 +1,16 @@
|
||||
[defaults]
|
||||
ansible_python_interpreter = /usr/bin/python3
|
||||
#inventory = inventory/hosts
|
||||
any_errors_fatal = true
|
||||
display_skipped_hosts = false
|
||||
deprecation_warnings = false
|
||||
gathering = smart
|
||||
log_path = output.log
|
||||
|
||||
[inventory]
|
||||
enable_plugins = host_list, virtualbox, yaml, constructed, script, auto, yaml, ini, toml
|
||||
|
||||
#[ssh_connection]
|
||||
#ssh_args = -o ControlMaster=auto -o ControlPersist=600s
|
||||
#control_path = %(directory)s/%%h-%%r
|
||||
#pipelining = true
|
1
bin/ansible/inventory/hosts
Normal file
1
bin/ansible/inventory/hosts
Normal file
@ -0,0 +1 @@
|
||||
localhost
|
18
bin/ansible/playbook.yml
Normal file
18
bin/ansible/playbook.yml
Normal file
@ -0,0 +1,18 @@
|
||||
- name: Clear log file before write new stdout to it at this session
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: echo -n > output.log
|
||||
shell: echo -n > output.log
|
||||
|
||||
- name: Lets Go!
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: Create directory for ansible custom facts
|
||||
debug:
|
||||
msg: "[ Python: {{ ansible_facts['python_version'] }}, OS: {{ ansible_facts['distribution'] }} {{ ansible_facts['distribution_version'] }} ({{ansible_architecture }}), Ansible: {{ ansible_version.full }}]"
|
||||
|
||||
- name: Generate Jira images
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
roles:
|
||||
- atlassian.jira.9
|
51
bin/ansible/roles/atlassian.jira.9/files/Dockerfile
Normal file
51
bin/ansible/roles/atlassian.jira.9/files/Dockerfile
Normal file
@ -0,0 +1,51 @@
|
||||
FROM epicmorg/debian:bullseye-jdk8
|
||||
LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org"
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##################################################################
|
||||
# ARGuments
|
||||
##################################################################
|
||||
|
||||
#configured by dockerfile / .ENV
|
||||
ARG RELEASE
|
||||
ARG DOWNLOAD_URL
|
||||
|
||||
##################################################################
|
||||
# Setup
|
||||
##################################################################
|
||||
ENV RUN_USER daemon
|
||||
ENV RUN_GROUP daemon
|
||||
|
||||
# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files
|
||||
ENV JIRA_HOME /var/atlassian/application-data/jira
|
||||
ENV JIRA_INSTALL_DIR /opt/atlassian/jira
|
||||
|
||||
VOLUME ["${JIRA_HOME}"]
|
||||
WORKDIR $JIRA_HOME
|
||||
|
||||
# Expose HTTP port
|
||||
EXPOSE 8080
|
||||
|
||||
##################################################################
|
||||
# Installing
|
||||
##################################################################
|
||||
RUN mkdir -p ${JIRA_INSTALL_DIR} \
|
||||
&& curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$JIRA_INSTALL_DIR" \
|
||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \
|
||||
&& sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \
|
||||
&& sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \
|
||||
&& sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \
|
||||
&& sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \
|
||||
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
|
||||
apt clean -y && \
|
||||
apt autoclean -y && \
|
||||
rm -rfv /var/lib/apt/lists/* && \
|
||||
rm -rfv /var/cache/apt/archives/*.deb
|
||||
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
CMD ["/entrypoint.sh", "-fg"]
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
#COPY . /tmp
|
50
bin/ansible/roles/atlassian.jira.9/files/Dockerfile.jdk11
Normal file
50
bin/ansible/roles/atlassian.jira.9/files/Dockerfile.jdk11
Normal file
@ -0,0 +1,50 @@
|
||||
FROM epicmorg/debian:bullseye-jdk11
|
||||
LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org"
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##################################################################
|
||||
# ARGuments
|
||||
##################################################################
|
||||
|
||||
#configured by dockerfile / .ENV
|
||||
ARG RELEASE
|
||||
ARG DOWNLOAD_URL
|
||||
|
||||
##################################################################
|
||||
# Setup
|
||||
##################################################################
|
||||
ENV RUN_USER daemon
|
||||
ENV RUN_GROUP daemon
|
||||
|
||||
# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files
|
||||
ENV JIRA_HOME /var/atlassian/application-data/jira
|
||||
ENV JIRA_INSTALL_DIR /opt/atlassian/jira
|
||||
|
||||
VOLUME ["${JIRA_HOME}"]
|
||||
WORKDIR $JIRA_HOME
|
||||
|
||||
# Expose HTTP port
|
||||
EXPOSE 8080
|
||||
|
||||
##################################################################
|
||||
# Installing
|
||||
##################################################################
|
||||
RUN mkdir -p ${JIRA_INSTALL_DIR} \
|
||||
&& curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$JIRA_INSTALL_DIR" \
|
||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \
|
||||
&& sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \
|
||||
&& sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \
|
||||
&& sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \
|
||||
&& sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \
|
||||
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
|
||||
apt clean -y && \
|
||||
apt autoclean -y && \
|
||||
rm -rfv /var/lib/apt/lists/* && \
|
||||
rm -rfv /var/cache/apt/archives/*.deb
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
CMD ["/entrypoint.sh", "-fg"]
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
#COPY . /tmp
|
50
bin/ansible/roles/atlassian.jira.9/files/Dockerfile.jdk17
Normal file
50
bin/ansible/roles/atlassian.jira.9/files/Dockerfile.jdk17
Normal file
@ -0,0 +1,50 @@
|
||||
FROM epicmorg/debian:bullseye-jdk11
|
||||
LABEL maintainer="Atlassian Jira Server Team; EpicMorg DevTeam, developer@epicm.org"
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
##################################################################
|
||||
# ARGuments
|
||||
##################################################################
|
||||
|
||||
#configured by dockerfile / .ENV
|
||||
ARG RELEASE
|
||||
ARG DOWNLOAD_URL
|
||||
|
||||
##################################################################
|
||||
# Setup
|
||||
##################################################################
|
||||
ENV RUN_USER daemon
|
||||
ENV RUN_GROUP daemon
|
||||
|
||||
# https://confluence.atlassian.com/display/JSERVERM/Important+directories+and+files
|
||||
ENV JIRA_HOME /var/atlassian/application-data/jira
|
||||
ENV JIRA_INSTALL_DIR /opt/atlassian/jira
|
||||
|
||||
VOLUME ["${JIRA_HOME}"]
|
||||
WORKDIR $JIRA_HOME
|
||||
|
||||
# Expose HTTP port
|
||||
EXPOSE 8080
|
||||
|
||||
##################################################################
|
||||
# Installing
|
||||
##################################################################
|
||||
RUN mkdir -p ${JIRA_INSTALL_DIR} \
|
||||
&& curl -L ${DOWNLOAD_URL} | tar -xz --strip-components=1 -C "$JIRA_INSTALL_DIR" \
|
||||
&& chown -R ${RUN_USER}:${RUN_GROUP} ${JIRA_INSTALL_DIR}/ \
|
||||
&& sed -i -e 's/^JVM_SUPPORT_RECOMMENDED_ARGS=""$/: \${JVM_SUPPORT_RECOMMENDED_ARGS:=""}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \
|
||||
&& sed -i -e 's/^JVM_\(.*\)_MEMORY="\(.*\)"$/: \${JVM_\1_MEMORY:=\2}/g' ${JIRA_INSTALL_DIR}/bin/setenv.sh \
|
||||
&& sed -i -e 's/grep "java version"/grep -E "(openjdk|java) version"/g' ${JIRA_INSTALL_DIR}/bin/check-java.sh \
|
||||
&& sed -i -e 's/port="8080"/port="8080" secure="${catalinaConnectorSecure}" scheme="${catalinaConnectorScheme}" proxyName="${catalinaConnectorProxyName}" proxyPort="${catalinaConnectorProxyPort}"/' ${JIRA_INSTALL_DIR}/conf/server.xml && \
|
||||
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
|
||||
apt clean -y && \
|
||||
apt autoclean -y && \
|
||||
rm -rfv /var/lib/apt/lists/* && \
|
||||
rm -rfv /var/cache/apt/archives/*.deb
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
CMD ["/entrypoint.sh", "-fg"]
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
#COPY . /tmp
|
19
bin/ansible/roles/atlassian.jira.9/files/Makefile
Normal file
19
bin/ansible/roles/atlassian.jira.9/files/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
all: app
|
||||
|
||||
app:
|
||||
make build
|
||||
make deploy
|
||||
make clean
|
||||
|
||||
build:
|
||||
docker-compose build --compress --parallel --progress plain
|
||||
|
||||
deploy:
|
||||
docker-compose push
|
||||
|
||||
clean:
|
||||
docker container prune -f
|
||||
docker image prune -f
|
||||
docker network prune -f
|
||||
docker volume prune -f
|
||||
docker system prune -af
|
25
bin/ansible/roles/atlassian.jira.9/files/docker-compose.yml
Normal file
25
bin/ansible/roles/atlassian.jira.9/files/docker-compose.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: '3.9'
|
||||
services:
|
||||
app:
|
||||
image: "epicmorg/jira:${RELEASE}"
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
DOWNLOAD_URL: ${DOWNLOAD_URL}
|
||||
app-jdk11:
|
||||
image: "epicmorg/jira:${RELEASE}-jdk11"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.jdk11
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
DOWNLOAD_URL: ${DOWNLOAD_URL}
|
||||
app-jdk17:
|
||||
image: "epicmorg/jira:${RELEASE}-jdk11"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.jdk11
|
||||
args:
|
||||
RELEASE: ${RELEASE}
|
||||
DOWNLOAD_URL: ${DOWNLOAD_URL}
|
89
bin/ansible/roles/atlassian.jira.9/files/entrypoint.sh
Normal file
89
bin/ansible/roles/atlassian.jira.9/files/entrypoint.sh
Normal file
@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
|
||||
export JRE_HOME="$JAVA_HOME/jre"
|
||||
export JAVA_BINARY="$JRE_HOME/bin/java"
|
||||
export JAVA_VERSION=$("$JAVA_BINARY" -version 2>&1 | awk -F '"' '/version/ {print $2}')
|
||||
|
||||
# Setup Catalina Opts
|
||||
: ${CATALINA_CONNECTOR_PROXYNAME:=}
|
||||
: ${CATALINA_CONNECTOR_PROXYPORT:=}
|
||||
: ${CATALINA_CONNECTOR_SCHEME:=http}
|
||||
: ${CATALINA_CONNECTOR_SECURE:=false}
|
||||
|
||||
: ${CATALINA_OPTS:=}
|
||||
|
||||
: ${JAVA_OPTS:=}
|
||||
|
||||
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyName=${CATALINA_CONNECTOR_PROXYNAME}"
|
||||
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorProxyPort=${CATALINA_CONNECTOR_PROXYPORT}"
|
||||
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorScheme=${CATALINA_CONNECTOR_SCHEME}"
|
||||
CATALINA_OPTS="${CATALINA_OPTS} -DcatalinaConnectorSecure=${CATALINA_CONNECTOR_SECURE}"
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} ${CATALINA_OPTS}"
|
||||
|
||||
# Setup Data Center configuration
|
||||
if [ ! -f "/etc/container_id" ]; then
|
||||
uuidgen > /etc/container_id
|
||||
fi
|
||||
CONTAINER_ID=$(cat /etc/container_id)
|
||||
CONTAINER_SHORT_ID=${CONTAINER_ID::8}
|
||||
|
||||
: ${CLUSTERED:=false}
|
||||
: ${JIRA_NODE_ID:=jira_node_${CONTAINER_SHORT_ID}}
|
||||
: ${JIRA_SHARED_HOME:=${JIRA_HOME}/shared}
|
||||
: ${EHCACHE_PEER_DISCOVERY:=}
|
||||
: ${EHCACHE_LISTENER_HOSTNAME:=}
|
||||
: ${EHCACHE_LISTENER_PORT:=}
|
||||
: ${EHCACHE_LISTENER_SOCKETTIMEOUTMILLIS:=}
|
||||
: ${EHCACHE_MULTICAST_ADDRESS:=}
|
||||
: ${EHCACHE_MULTICAST_PORT:=}
|
||||
: ${EHCACHE_MULTICAST_TIMETOLIVE:=}
|
||||
: ${EHCACHE_MULTICAST_HOSTNAME:=}
|
||||
|
||||
# Cleanly set/unset values in cluster.properties
|
||||
function set_cluster_property {
|
||||
if [ -z $2 ]; then
|
||||
if [ -f "${JIRA_HOME}/cluster.properties" ]; then
|
||||
sed -i -e "/^${1}/d" "${JIRA_HOME}/cluster.properties"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
if [ ! -f "${JIRA_HOME}/cluster.properties" ]; then
|
||||
echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties"
|
||||
elif grep "^${1}" "${JIRA_HOME}/cluster.properties"; then
|
||||
sed -i -e "s#^${1}=.*#${1}=${2}#g" "${JIRA_HOME}/cluster.properties"
|
||||
else
|
||||
echo "${1}=${2}" >> "${JIRA_HOME}/cluster.properties"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${CLUSTERED}" == "true" ]; then
|
||||
set_cluster_property "jira.node.id" "${JIRA_NODE_ID}"
|
||||
set_cluster_property "jira.shared.home" "${JIRA_SHARED_HOME}"
|
||||
set_cluster_property "ehcache.peer.discovery" "${EHCACHE_PEER_DISCOVERY}"
|
||||
set_cluster_property "ehcache.listener.hostName" "${EHCACHE_LISTENER_HOSTNAME}"
|
||||
set_cluster_property "ehcache.listener.port" "${EHCACHE_LISTENER_PORT}"
|
||||
set_cluster_property "ehcache.listener.socketTimeoutMillis" "${EHCACHE_LISTENER_PORT}"
|
||||
set_cluster_property "ehcache.multicast.address" "${EHCACHE_MULTICAST_ADDRESS}"
|
||||
set_cluster_property "ehcache.multicast.port" "${EHCACHE_MULTICAST_PORT}"
|
||||
set_cluster_property "ehcache.multicast.timeToLive" "${EHCACHE_MULTICAST_TIMETOLIVE}"
|
||||
set_cluster_property "ehcache.multicast.hostName" "${EHCACHE_MULTICAST_HOSTNAME}"
|
||||
fi
|
||||
|
||||
|
||||
# Start Jira as the correct user
|
||||
if [ "${UID}" -eq 0 ]; then
|
||||
echo "User is currently root. Will change directory ownership to ${RUN_USER}:${RUN_GROUP}, then downgrade permission to ${RUN_USER}"
|
||||
PERMISSIONS_SIGNATURE=$(stat -c "%u:%U:%a" "${JIRA_HOME}")
|
||||
EXPECTED_PERMISSIONS=$(id -u ${RUN_USER}):${RUN_USER}:700
|
||||
if [ "${PERMISSIONS_SIGNATURE}" != "${EXPECTED_PERMISSIONS}" ]; then
|
||||
chmod -R 700 "${JIRA_HOME}" &&
|
||||
chown -R "${RUN_USER}:${RUN_GROUP}" "${JIRA_HOME}"
|
||||
fi
|
||||
# Now drop privileges
|
||||
exec su -s /bin/bash "${RUN_USER}" -c "$JIRA_INSTALL_DIR/bin/start-jira.sh $@"
|
||||
else
|
||||
exec "$JIRA_INSTALL_DIR/bin/start-jira.sh" "$@"
|
||||
fi
|
30
bin/ansible/roles/atlassian.jira.9/tasks/main.yml
Normal file
30
bin/ansible/roles/atlassian.jira.9/tasks/main.yml
Normal file
@ -0,0 +1,30 @@
|
||||
- name: Read versions from file
|
||||
slurp:
|
||||
src: "{{ versions_file }}"
|
||||
register: version_output
|
||||
|
||||
- name: Set version variable
|
||||
set_fact:
|
||||
jira_versions: "{{ version_output['content'] | b64decode | trim | split('\n') }}"
|
||||
|
||||
- name: Create directories for Jira versions
|
||||
file:
|
||||
path: "{{ target_directory }}/{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
with_items: "{{ jira_versions }}"
|
||||
|
||||
- name: Copy template with link to each version directory
|
||||
template:
|
||||
src: "template.env.j2"
|
||||
dest: "{{ target_directory }}/{{ item }}/.env"
|
||||
with_items: "{{ jira_versions }}"
|
||||
|
||||
- name: Copy all files from 'files' directory to each version directory
|
||||
copy:
|
||||
src: "files/"
|
||||
dest: "{{ target_directory }}/{{ item }}/"
|
||||
with_items: "{{ jira_versions }}"
|
||||
# no_log: true
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
RELEASE={{ item }}
|
||||
DOWNLOAD_URL=https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-${RELEASE}.tar.gz
|
4
bin/ansible/roles/atlassian.jira.9/vars/main.yml
Normal file
4
bin/ansible/roles/atlassian.jira.9/vars/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
# Defaults
|
||||
versions_file: "roles/common/files/versions/jira/9.txt"
|
||||
target_directory: "/opt/tmp/jira/"
|
||||
template_file: "template.env.j2"
|
2
bin/ansible/roles/common/files/versions/jira/9.txt
Normal file
2
bin/ansible/roles/common/files/versions/jira/9.txt
Normal file
@ -0,0 +1,2 @@
|
||||
x.x.x.x
|
||||
y.y.y.y
|
Loading…
x
Reference in New Issue
Block a user