diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/dockerhost.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/dockerhost.yml new file mode 100644 index 0000000000..a32501ad32 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/dockerhost.yml @@ -0,0 +1,42 @@ +--- +################################### +# AdoptOpenJDK - Ansible Playbook # +################################### +# Groups can be passed in as a command-line variable in Ansible playbook. +# It can be defined as 'all' or a specific group which the host belongs to. +# For example, it can be 'all' or 'x86' for when a host is in the group 'x86'. +#- hosts: "{{ Groups | default('localhost:docker:!*zos*:!*win*:!*aix*') }}" +- hosts: all + gather_facts: yes + tasks: + - block: + # Set standard variables + - name: Load AdoptOpenJDKs variable file + include_vars: group_vars/all/adoptopenjdk_variables.yml + + ######### + # Roles # + ######### + roles: + - Debug + - Version + - adopt_etc + - Providers # AdoptOpenJDK Infrastructure + - Get_Vendor_Files + - Jenkins_User # AdoptOpenJDK Infrastructure + - Superuser # AdoptOpenJDK Infrastructure + - role: Swap_File + - role: Crontab + - role: adoptopenjdk_install + jdk_version: 11 + - role: Nagios_Plugins # AdoptOpenJDK Infrastructure + tags: [nagios_plugins, adoptopenjdk] + - role: Nagios_Master_Config # AdoptOpenJDK Infrastructure + tags: [nagios_master_config, adoptopenjdk] + - role: Nagios_Tunnel # AdoptOpenJDK Infrastructure + tags: [nagios_tunnel, adoptopenjdk] + - Security + - Vendor + - IPv6 + - Docker + - DockerStatic diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml index f8a5dd91fa..ca5e284d4c 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml @@ -23,6 +23,7 @@ - role: Get_Vendor_Files tags: [vendor_files, adoptopenjdk, jenkins_user, nagios_plugins, superuser] - Version + - adopt_etc - Common - Providers # AdoptOpenJDK Infrastructure - autoconf diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/CentOS.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/CentOS.yml index d7920d58e5..c83819c2be 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/CentOS.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/CentOS.yml @@ -89,5 +89,3 @@ Test_Tool_Packages: - xorg-x11-xauth - xorg-x11-server-Xorg - xorg-x11-server-Xvfb - -crontab_Patching: "/usr/bin/yum -y update" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Debian.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Debian.yml index 188bb39603..1aab95c472 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Debian.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Debian.yml @@ -102,5 +102,3 @@ Test_Tool_Packages: Test_Tool_Packages_x86_64: - pulseaudio - -crontab_Patching: "/usr/bin/apt-get update && /usr/bin/apt-get -y upgrade" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/FreeBSD.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/FreeBSD.yml index eca1525f0d..7404acb1d1 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/FreeBSD.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/FreeBSD.yml @@ -43,5 +43,3 @@ Test_Tool_Packages: - xorg - xorg-vfbserver - pulseaudio - -crontab_Patching: "/usr/sbin/pkg update && /usr/sbin/pkg upgrade -y" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/RedHat.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/RedHat.yml index f726107972..e2090bf124 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/RedHat.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/RedHat.yml @@ -98,5 +98,3 @@ Test_Tool_Packages: - perl-devel - expat-devel - libcurl-devel - -crontab_Patching: "/usr/bin/yum -y update && yum clean packages" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/SLES.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/SLES.yml index 09699c9d3d..32bd1c2c12 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/SLES.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/SLES.yml @@ -77,5 +77,3 @@ Test_Tool_Packages: - xorg-x11-server - xorg-x11-server-extra - glibc-locale # Internationalization tests - -crontab_Patching: "/usr/bin/zypper refresh && /usr/bin/zypper -n up" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Solaris.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Solaris.yml index fb51b311b1..46a17de2a8 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Solaris.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Solaris.yml @@ -26,5 +26,3 @@ Build_Tool_Packages: Test_Tool_Packages: - perl - -crontab_Patching: "/opt/csw/bin/pkgutil --upgrade --yes" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Ubuntu.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Ubuntu.yml index 6cfe9057df..7e91143b82 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Ubuntu.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/Ubuntu.yml @@ -114,5 +114,3 @@ Test_Tool_Packages: Test_Tool_Packages_x86_64: - pulseaudio - -crontab_Patching: "/usr/bin/apt-get update && /usr/bin/apt-get -y upgrade" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/openSUSE.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/openSUSE.yml index 39ddab891b..1f7dc641ab 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/openSUSE.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Common/vars/openSUSE.yml @@ -65,5 +65,3 @@ Test_Tool_Packages: - xorg-x11-server - xorg-x11-server-extra - glibc-locale # Internationalization tests - -crontab_Patching: "/usr/bin/zypper refresh && /usr/bin/zypper -n up" diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Crontab/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Crontab/tasks/main.yml index ec7c8c5f95..e28b91b1d0 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Crontab/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/Crontab/tasks/main.yml @@ -2,12 +2,33 @@ ########### # Crontab # ########### -- name: Add cron job to check for updates - cron: name="Check for updates everyday at 1am" - weekday="*" - minute="0" - hour="1" - user=root - job="{{ crontab_Patching }}" - state=present + +- name: Add cron job to apply OS updates on yum-based systems + cron: name="Check for updates everyday at 1am" weekday="*" minute="0" hour="1" user=root state=present + job="/usr/bin/yum -y update" + when: (ansible_distribution == "RedHat" or ansible_distribution == "CentOS") + tags: crontab + +- name: Add cron job to apply OS updates on apt-based systems + cron: name="Check for updates everyday at 1am" weekday="*" minute="0" hour="1" user=root state=present + job="/usr/bin/apt-get update && /usr/bin/apt-get -y upgrade" + when: (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu") + tags: crontab + +- name: Add cron job to apply OS updates on zypper-based systems + cron: name="Check for updates everyday at 1am" weekday="*" minute="0" hour="1" user=root state=present + job="/usr/bin/zypper refresh && /usr/bin/zypper -n up" + when: (ansible_distribution == "SLES" or ansible_distribution == "openSUSE") + tags: crontab + +- name: Add cron job to apply OS updates on FreeBSD systems + cron: name="Check for updates everyday at 1am" weekday="*" minute="0" hour="1" user=root state=present + job="/usr/sbin/pkg update && /usr/sbin/pkg upgrade -y" + when: (ansible_distribution == "FreeBSD") + tags: crontab + +- name: Add cron job to apply OS updates on Solaris systems + cron: name="Check for updates everyday at 1am" weekday="*" minute="0" hour="1" user=root state=present + job="/opt/csw/bin/pkgutil --upgrade --yes" + when: (ansible_distribution == "Solaris") tags: crontab diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.cent8 b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.cent8 new file mode 100644 index 0000000000..5a93036bf1 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.cent8 @@ -0,0 +1,27 @@ +FROM centos:8 + +RUN dnf -y update && dnf install -y perl openssh-server unzip wget +RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -P "" +# Get java8 +RUN wget -q 'https://api.adoptopenjdk.net/v2/binary/releases/openjdk8?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&type=jdk' -O /tmp/jdk8.tar.gz +RUN mkdir -p /usr/lib/jvm/jdk8 && tar -xpzf /tmp/jdk8.tar.gz -C /usr/lib/jvm/jdk8 --strip-components=1 +# Install ant +RUN wget -q -O /tmp/ant.zip 'https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip' +RUN wget -q -O /tmp/ant-contrib.tgz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz +RUN ln -s /usr/local/apache-ant-1.10.5/bin/ant /usr/bin/ant +RUN unzip -q -d /usr/local /tmp/ant.zip +RUN tar xpfz /tmp/ant-contrib.tgz -C /usr/local/apache-ant-1.10.5/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar +# Clear up space +RUN rm /tmp/jdk8.tar.gz /tmp/ant.zip /tmp/ant-contrib.tgz +# Set up jenkins user +RUN useradd -m -d /home/jenkins jenkins +RUN mkdir /home/jenkins/.ssh +RUN echo "Jenkins_User_SSHKey" > /home/jenkins/.ssh/authorized_keys +RUN chown -R jenkins /home/jenkins/.ssh +RUN chmod -R og-rwx /home/jenkins/.ssh +# RUN service ssh start +CMD ["/usr/sbin/sshd","-D"] +RUN dnf install -y git curl make gcc xorg-x11-server-Xvfb libXrender libXi libXtst +# ENTRYPOINT /usr/lib/jvm/jdk8/bin/java +EXPOSE 22 +# Start with docker run -p 2222:22 UUID diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.f33 b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.f33 new file mode 100644 index 0000000000..a38f35845c --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.f33 @@ -0,0 +1,27 @@ +FROM fedora:33 + +RUN yum -y update && yum install -y perl openssh-server unzip wget +RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -P "" +# Get java8 +RUN wget -q 'https://api.adoptopenjdk.net/v2/binary/releases/openjdk8?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&type=jdk' -O /tmp/jdk8.tar.gz +RUN mkdir -p /usr/lib/jvm/jdk8 && tar -xpzf /tmp/jdk8.tar.gz -C /usr/lib/jvm/jdk8 --strip-components=1 +# Install ant +RUN wget -q -O /tmp/ant.zip 'https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip' +RUN wget -q -O /tmp/ant-contrib.tgz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz +RUN ln -s /usr/local/apache-ant-1.10.5/bin/ant /usr/bin/ant +RUN unzip -q -d /usr/local /tmp/ant.zip +RUN tar xpfz /tmp/ant-contrib.tgz -C /usr/local/apache-ant-1.10.5/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar +# Clear up space +RUN rm /tmp/jdk8.tar.gz /tmp/ant.zip /tmp/ant-contrib.tgz +# Set up jenkins user +RUN useradd -m -d /home/jenkins jenkins +RUN mkdir /home/jenkins/.ssh +RUN echo "Jenkins_User_SSHKey" > /home/jenkins/.ssh/authorized_keys +RUN chown -R jenkins /home/jenkins/.ssh +RUN chmod -R og-rwx /home/jenkins/.ssh +# RUN service ssh start +CMD ["/usr/sbin/sshd","-D"] +RUN yum install -y git curl make gcc xorg-x11-server-Xvfb libXrender libXi libXtst procps +# ENTRYPOINT /usr/lib/jvm/jdk8/bin/java +EXPOSE 22 +# Start with docker run -p 2222:22 UUID diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u1604 b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u1604 new file mode 100644 index 0000000000..77f6d3343a --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u1604 @@ -0,0 +1,27 @@ +FROM ubuntu:16.04 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -qq -y perl openssh-server unzip +# Get java8 +RUN wget -q 'https://api.adoptopenjdk.net/v2/binary/releases/openjdk8?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&type=jdk' -O /tmp/jdk8.tar.gz +RUN mkdir -p /usr/lib/jvm/jdk8 && tar -xpzf /tmp/jdk8.tar.gz -C /usr/lib/jvm/jdk8 --strip-components=1 +# Install ant +RUN wget -q -O /tmp/ant.zip 'https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip' +RUN wget -q -O /tmp/ant-contrib.tgz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz +RUN ln -s /usr/local/apache-ant-1.10.5/bin/ant /usr/bin/ant +RUN unzip -q -d /usr/local /tmp/ant.zip +RUN tar xpfz /tmp/ant-contrib.tgz -C /usr/local/apache-ant-1.10.5/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar +# Clear up space +RUN rm /tmp/jdk8.tar.gz /tmp/ant.zip /tmp/ant-contrib.tgz +# Set up jenkins user +RUN useradd -m -d /home/jenkins jenkins +RUN mkdir /home/jenkins/.ssh +RUN echo "Jenkins_User_SSHKey" > /home/jenkins/.ssh/authorized_keys +RUN chown -R jenkins /home/jenkins/.ssh +RUN chmod -R og-rwx /home/jenkins/.ssh +RUN service ssh start +CMD ["/usr/sbin/sshd","-D"] +RUN apt-get update && apt-get install -qq -y git curl make gcc xvfb libxrender1 libxi6 libxtst6 +# ENTRYPOINT /usr/lib/jvm/jdk8/bin/java +EXPOSE 22 +# Start with docker run -p 2222:22 UUID diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u1804 b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u1804 new file mode 100644 index 0000000000..c2806d59f9 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u1804 @@ -0,0 +1,27 @@ +FROM ubuntu:18.04 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -qq -y perl openssh-server unzip +# Get java8 +RUN wget -q 'https://api.adoptopenjdk.net/v2/binary/releases/openjdk8?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&type=jdk' -O /tmp/jdk8.tar.gz +RUN mkdir -p /usr/lib/jvm/jdk8 && tar -xpzf /tmp/jdk8.tar.gz -C /usr/lib/jvm/jdk8 --strip-components=1 +# Install ant +RUN wget -q -O /tmp/ant.zip 'https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip' +RUN wget -q -O /tmp/ant-contrib.tgz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz +RUN ln -s /usr/local/apache-ant-1.10.5/bin/ant /usr/bin/ant +RUN unzip -q -d /usr/local /tmp/ant.zip +RUN tar xpfz /tmp/ant-contrib.tgz -C /usr/local/apache-ant-1.10.5/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar +# Clear up space +RUN rm /tmp/jdk8.tar.gz /tmp/ant.zip /tmp/ant-contrib.tgz +# Set up jenkins user +RUN useradd -m -d /home/jenkins jenkins +RUN mkdir /home/jenkins/.ssh +RUN echo "Jenkins_User_SSHKey" > /home/jenkins/.ssh/authorized_keys +RUN chown -R jenkins /home/jenkins/.ssh +RUN chmod -R og-rwx /home/jenkins/.ssh +RUN service ssh start +CMD ["/usr/sbin/sshd","-D"] +RUN apt-get update && apt-get install -qq -y git curl make gcc xvfb libxrender1 libxi6 libxtst6 +# ENTRYPOINT /usr/lib/jvm/jdk8/bin/java +EXPOSE 22 +# Start with docker run -p 2222:22 UUID diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u2004 b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u2004 new file mode 100644 index 0000000000..ec668de4e9 --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u2004 @@ -0,0 +1,27 @@ +FROM ubuntu:20.04 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -qq -y perl openssh-server unzip +# Get java8 +RUN wget -q 'https://api.adoptopenjdk.net/v2/binary/releases/openjdk8?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&type=jdk' -O /tmp/jdk8.tar.gz +RUN mkdir -p /usr/lib/jvm/jdk8 && tar -xpzf /tmp/jdk8.tar.gz -C /usr/lib/jvm/jdk8 --strip-components=1 +# Install ant +RUN wget -q -O /tmp/ant.zip 'https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip' +RUN wget -q -O /tmp/ant-contrib.tgz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz +RUN ln -s /usr/local/apache-ant-1.10.5/bin/ant /usr/bin/ant +RUN unzip -q -d /usr/local /tmp/ant.zip +RUN tar xpfz /tmp/ant-contrib.tgz -C /usr/local/apache-ant-1.10.5/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar +# Clear up space +RUN rm /tmp/jdk8.tar.gz /tmp/ant.zip /tmp/ant-contrib.tgz +# Set up jenkins user +RUN useradd -m -d /home/jenkins jenkins +RUN mkdir /home/jenkins/.ssh +RUN echo "Jenkins_User_SSHKey" > /home/jenkins/.ssh/authorized_keys +RUN chown -R jenkins /home/jenkins/.ssh +RUN chmod -R og-rwx /home/jenkins/.ssh +RUN service ssh start +CMD ["/usr/sbin/sshd","-D"] +RUN apt-get update && apt-get install -qq -y git curl make gcc xvfb libxrender1 libxi6 libxtst6 +# ENTRYPOINT /usr/lib/jvm/jdk8/bin/java +EXPOSE 22 +# Start with docker run -p 2222:22 UUID diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u2010 b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u2010 new file mode 100644 index 0000000000..1c82bb68fb --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/Dockerfiles/Dockerfile.u2010 @@ -0,0 +1,27 @@ +FROM ubuntu:20.10 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -qq -y perl openssh-server unzip +# Get java8 +RUN wget -q 'https://api.adoptopenjdk.net/v2/binary/releases/openjdk8?openjdk_impl=hotspot&os=linux&arch=x64&release=latest&type=jdk' -O /tmp/jdk8.tar.gz +RUN mkdir -p /usr/lib/jvm/jdk8 && tar -xpzf /tmp/jdk8.tar.gz -C /usr/lib/jvm/jdk8 --strip-components=1 +# Install ant +RUN wget -q -O /tmp/ant.zip 'https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip' +RUN wget -q -O /tmp/ant-contrib.tgz https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.tar.gz +RUN ln -s /usr/local/apache-ant-1.10.5/bin/ant /usr/bin/ant +RUN unzip -q -d /usr/local /tmp/ant.zip +RUN tar xpfz /tmp/ant-contrib.tgz -C /usr/local/apache-ant-1.10.5/lib --strip-components=2 ant-contrib/lib/ant-contrib.jar +# Clear up space +RUN rm /tmp/jdk8.tar.gz /tmp/ant.zip /tmp/ant-contrib.tgz +# Set up jenkins user +RUN useradd -m -d /home/jenkins jenkins +RUN mkdir /home/jenkins/.ssh +RUN echo "Jenkins_User_SSHKey" > /home/jenkins/.ssh/authorized_keys +RUN chown -R jenkins /home/jenkins/.ssh +RUN chmod -R og-rwx /home/jenkins/.ssh +RUN service ssh start +CMD ["/usr/sbin/sshd","-D"] +RUN apt-get update && apt-get install -qq -y git curl make gcc xvfb libxrender1 libxi6 libxtst6 +# ENTRYPOINT /usr/lib/jvm/jdk8/bin/java +EXPOSE 22 +# Start with docker run -p 2222:22 UUID diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/tasks/main.yml new file mode 100644 index 0000000000..d8f37ab67b --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/DockerStatic/tasks/main.yml @@ -0,0 +1,84 @@ +--- +################################################# +# Build basic test images for each distribution # +################################################# + +- name: Send Dockerfiles to remote machine + copy: + src: Dockerfiles/ + dest: /tmp/Dockerfiles/ + +- name: Collate all Dockerfile names + find: + paths: "/tmp/Dockerfiles/" + patterns: "Dockerfile.*" + register: dockerfiles + +# Defaulting to x64 in Dockerfiles means no need to special case that one +# since API architecture = ansible_architecture everywhere else we use this +- name: Translate architecture name in dockerfiles + replace: dest={{ item.path }} regexp="arch=x64" replace="arch={{ ansible_architecture }}" + with_items: "{{ dockerfiles.files }}" + when: ansible_architecture != "x86_64" + +- name: Set jenkins authorized_Key in dockerfiles + replace: dest={{ item.path }} regexp="Jenkins_User_SSHKey" replace="{{ Jenkins_User_SSHKey }}" + with_items: "{{ dockerfiles.files }}" + +- name: Create docker images for each distribution for test + command: docker build --cpu-period=100000 --cpu-quota=800000 -t aqa_{{ item }} --memory=8G -f /tmp/Dockerfiles/Dockerfile.{{ item }} /tmp/Dockerfiles + with_items: + - u1604 + - u1804 + - u2004 + - u2010 + - f33 + +############################################################## +# Start the containers # +# If startallcontainers is skipped, only start three of them # +# ignore_errors simplest way to ignore if already started # +# # +# TODO: Check if started rather than ignore error? # +# TODO: Restart if already started? (Use galaxy role?) # +# TODO: Use a calculated value instead of 2 core/6Gb # +############################################################## + +- name: Start Ubuntu 16.04 container if not already started + command: docker run --restart unless-stopped -p 2222:22 --cpus=2.0 --memory=6G --detach --name U1604_2222 aqa_u1604 + tags: startcontainers + ignore_errors: yes + +- name: Start Ubuntu 18.04 container if not already started + command: docker run --restart unless-stopped -p 2223:22 --cpus=4.0 --memory=6G --detach --name U1804_2223 aqa_u1804 + tags: startcontainers, startallcontainers + ignore_errors: yes + +- name: Start Ubuntu 20.04 container if not already started + command: docker run --restart unless-stopped -p 2224:22 --cpus=2.0 --memory=6G --detach --name U2004_2224 aqa_u2004 + tags: startcontainers + ignore_errors: yes + +- name: Start Ubuntu 20.10 container if not already started + command: docker run --restart unless-stopped -p 2225:22 --cpus=4.0 --memory=6G --detach --name U2010_2225 aqa_u2010 + tags: startcontainers, startallcontainers + ignore_errors: yes + +- name: Start fedora 33 container if not already started + command: docker run --restart unless-stopped -p 2227:22 --cpus=2.0 --memory=6G --detach --name f33.2227 aqa_f33 + tags: startcontainers + ignore_errors: yes + +# lineinfile does not work here - similar to the operation in /var/log in adopt_etc +# lineinfile: path /proc/sys/kernel/core_pattern state: present: regexp: . line: core.%p +# therefore the following section wil not become live prior to a reboot +# +- name: Make core file setting live immediately; + command: "echo core.%p > /proc/sys/kernel/core_pattern" + +- name: Ensure core files are able to be created within docker containers on reboot + lineinfile: + path: /etc/sysctl.conf + state: present + regexp: kernel_core_pattern + line: kernel.core_pattern=core.%p diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adopt_etc/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adopt_etc/tasks/main.yml new file mode 100644 index 0000000000..531df1c33b --- /dev/null +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adopt_etc/tasks/main.yml @@ -0,0 +1,117 @@ +--- +######## +# Main # +######## + +########################### +# Overide amd64 to x86_64 # +########################### +- name: If ansible_architecture is amd64 set it to x86_64 + set_fact: + ansible_architecture: "x86_64" + when: + - ansible_architecture == "amd64" + +################## +# Set root group # +################## +- name: Set default root group to root + set_fact: + root_group: "root" + +################ +# Set Hostname # +################ +- name: Set hostname to inventory_hostname + hostname: + name: "{{ inventory_hostname }}.{{ Domain }}" + when: + - Domain == "adoptopenjdk.net" and ansible_distribution != "MacOSX" and ansible_distribution != "Solaris" + - inventory_hostname != ansible_default_ipv4.address + - inventory_hostname != "localhost" + tags: hostname,adoptopenjdk + +- name: Set hostname to inventory_hostname (macOS) + command: "{{ item }}" + with_items: + - "sudo scutil --set HostName {{ inventory_hostname }}.adoptopenjdk.net" + - "sudo scutil --set ComputerName {{ inventory_hostname }}.adoptopenjdk.net" + - "dscacheutil -flushcache" + when: + - Domain == "adoptopenjdk.net" and ansible_distribution == "MacOSX" + - inventory_hostname != ansible_default_ipv4.address + - inventory_hostname != "localhost" + tags: hostname,adoptopenjdk + +- name: Set hostname to inventory_hostname (Solaris) + shell: "{{ item }}" + with_items: + - echo "{{ inventory_hostname }}" > /etc/nodename + - echo "{{ inventory_hostname }}" > /etc/hostname.e1000g0 + - uname -S "{{ inventory_hostname }}" + when: Domain == "adoptopenjdk.net" and ansible_distribution == "Solaris" + register: foo + tags: hostname,adoptopenjdk + +##################### +# Update /etc/hosts # +##################### +- name: Update /etc/hosts file - IP FQDN hostname + lineinfile: + dest: /etc/hosts + regexp: "^(.*){{ ansible_hostname }}(.*)$" + line: "{{ ansible_default_ipv4.address }} {{ inventory_hostname }}.{{ Domain }} {{ inventory_hostname }}" + state: present + when: + - Domain == "adoptopenjdk.net" + - inventory_hostname != ansible_default_ipv4.address + - inventory_hostname != "localhost" + tags: hosts_file, adoptopenjdk + +- name: Update /etc/hosts file - IP FQDN hostname (Domain != "adoptopenjdk.net") + lineinfile: + dest: /etc/hosts + regexp: "^(.*){{ ansible_hostname }}(.*)$" + line: "{{ ansible_default_ipv4.address }} {{ ansible_fqdn }} {{ ansible_hostname }}" + state: present + when: + - Domain != "adoptopenjdk.net" + - inventory_hostname != ansible_default_ipv4.address + - inventory_hostname != "localhost" + tags: hosts_file, adoptopenjdk + +- debug: + msg: "Inventory_hostname is the same as the ip address or is localhost. + The fqdn has not been added to /etc/hosts. + The hostname of the machine has not been updated. + Manually add the fqdn to /etc/hosts + and manually update the hostname in /etc/hostname. + Or use the command line argument --extra-vars 'inventory_hostname=', + when running the playbook next time" + when: (inventory_hostname == ansible_default_ipv4.address) or (inventory_hostname == "localhost") + tags: hosts_file, hostname + +- name: Update /etc/hosts file - 127.0.0.1 + lineinfile: + dest: /etc/hosts + regexp: "^(.*)127.0.0.1(.*)$" + line: "127.0.0.1 localhost localhost.localdomain" + state: present + backup: yes + tags: hosts_file, adoptopenjdk + +# This doesn't work as ansible says it can't write to the directory +# Leaving this here in case someoen can make it work in the future +# +#- name: Record playbook completion with time in /var/log/ansiblerun.log +# lineinfile: +# state: present +# create: yes +# path: /var/tmp/ansiblerun.log +# mode: 0644 +# line: "{{ ansible_date_time.iso8601_basic_short }} END" +# tags: ansiblerunlog + +# Version of the above that works +- name: Record playbook completion with time in /var/log/ansiblerun.log + command: echo $(date +%Y%m%dT%H%M%S) >> /var/log/ansiblerun.log