Skip to content

Commit db2fa36

Browse files
committed
Added molecule to improve testing in development
1 parent c9acb8f commit db2fa36

File tree

21 files changed

+698
-2
lines changed

21 files changed

+698
-2
lines changed

changelogs/fragments/molecule.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- Added molecule to improve testing in development ()

doc/development.adoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,22 @@ vagrant cloud provider create ${boxname} virtualbox "$vagrantversion"
202202
vagrant cloud provider upload ${boxname} virtualbox "$vagrantversion" ../../builds/oracle-7.9.virtualbox.box
203203
vagrant cloud publish --release ${boxname} "$vagrantversion" virtualbox
204204
----
205+
206+
== ansible molecule
207+
208+
.Docker pull Oracle XE
209+
210+
Normal SSO-Login from Oracle is needed for login to docker registry.
211+
212+
----
213+
docker login container-registry.oracle.com
214+
docker pull container-registry.oracle.com/database/express:21.3.0-xe
215+
----
216+
217+
.Start Oracle Container for test
218+
----
219+
docker run -d --name oracle-xe \
220+
-e ORACLE_PWD=Oracle_123 \
221+
-p 1521:1521 \
222+
container-registry.oracle.com/database/express:21.3.0-xe
223+
----
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM registry.suse.com/bci/bci-base:15.3
2+
LABEL maintainer="Thorsten Bruhns"
3+
ENV container=docker
4+
5+
ENV pip_packages "ansible"
6+
7+
# Install systemd -- See https://hub.docker.com/_/centos/
8+
RUN zypper -n install systemd; zypper clean ; \
9+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
10+
rm -f /etc/systemd/system/*.wants/*;\
11+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
12+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
13+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
14+
rm -f /lib/systemd/system/basic.target.wants/*;\
15+
rm -f /lib/systemd/system/anaconda.target.wants/*;
16+
17+
# Install requirements.
18+
RUN zypper refresh \
19+
&& zypper install -y \
20+
sudo \
21+
which \
22+
hostname \
23+
python3 \
24+
python3-pip \
25+
python3-wheel \
26+
python3-PyYAML \
27+
&& zypper clean -a
28+
29+
# Upgrade pip to latest version.
30+
RUN pip3 install --upgrade pip
31+
32+
# Install Ansible via Pip.
33+
RUN pip3 install $pip_packages
34+
35+
# Disable requiretty.
36+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
37+
38+
# Install Ansible inventory file.
39+
RUN mkdir -p /etc/ansible
40+
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
41+
42+
VOLUME ["/sys/fs/cgroup"]
43+
CMD ["/usr/lib/systemd/systemd"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM registry.suse.com/bci/bci-base:15.4
2+
LABEL maintainer="Thorsten Bruhns"
3+
ENV container=docker
4+
5+
ENV pip_packages "ansible"
6+
7+
# Install systemd -- See https://hub.docker.com/_/centos/
8+
RUN zypper -n install systemd; zypper clean ; \
9+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
10+
rm -f /etc/systemd/system/*.wants/*;\
11+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
12+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
13+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
14+
rm -f /lib/systemd/system/basic.target.wants/*;\
15+
rm -f /lib/systemd/system/anaconda.target.wants/*;
16+
17+
# Install requirements.
18+
RUN zypper refresh \
19+
&& zypper install -y \
20+
sudo \
21+
which \
22+
hostname \
23+
python3 \
24+
python3-pip \
25+
python3-wheel \
26+
python3-PyYAML \
27+
&& zypper clean -a
28+
29+
# Upgrade pip to latest version.
30+
RUN pip3 install --upgrade pip
31+
32+
# Install Ansible via Pip.
33+
RUN pip3 install $pip_packages
34+
35+
# Disable requiretty.
36+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
37+
38+
# Install Ansible inventory file.
39+
RUN mkdir -p /etc/ansible
40+
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
41+
42+
VOLUME ["/sys/fs/cgroup"]
43+
CMD ["/usr/lib/systemd/systemd"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM registry.suse.com/bci/bci-base:15.5
2+
LABEL maintainer="Thorsten Bruhns"
3+
ENV container=docker
4+
5+
ENV pip_packages "ansible"
6+
7+
# Install systemd -- See https://hub.docker.com/_/centos/
8+
RUN zypper -n install systemd; zypper clean ; \
9+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
10+
rm -f /etc/systemd/system/*.wants/*;\
11+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
12+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
13+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
14+
rm -f /lib/systemd/system/basic.target.wants/*;\
15+
rm -f /lib/systemd/system/anaconda.target.wants/*;
16+
17+
# Install requirements.
18+
RUN zypper refresh \
19+
&& zypper install -y \
20+
sudo \
21+
which \
22+
hostname \
23+
python3 \
24+
python3-pip \
25+
python3-wheel \
26+
python3-PyYAML \
27+
&& zypper clean -a
28+
29+
# Upgrade pip to latest version.
30+
RUN pip3 install --upgrade pip
31+
32+
# Install Ansible via Pip.
33+
RUN pip3 install $pip_packages
34+
35+
# Disable requiretty.
36+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
37+
38+
# Install Ansible inventory file.
39+
RUN mkdir -p /etc/ansible
40+
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
41+
42+
VOLUME ["/sys/fs/cgroup"]
43+
CMD ["/usr/lib/systemd/systemd"]

docker/molecule/Dockerfile-ol7

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM oraclelinux:7
2+
LABEL maintainer="Thorsten Bruhns"
3+
# Original code is copied from:
4+
# https://raw.githubusercontent.com/geerlingguy/docker-ubi8-ansible/master/Dockerfile
5+
#
6+
ENV container=docker
7+
8+
ENV pip_packages "ansible"
9+
10+
# Silence annoying subscription messages.
11+
RUN echo "enabled=0" >> /etc/yum/pluginconf.d/subscription-manager.conf
12+
13+
# Install systemd -- See https://hub.docker.com/_/centos/
14+
RUN yum -y update; yum clean all; \
15+
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
16+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
17+
rm -f /etc/systemd/system/*.wants/*;\
18+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
19+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
20+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
21+
rm -f /lib/systemd/system/basic.target.wants/*;\
22+
rm -f /lib/systemd/system/anaconda.target.wants/*;
23+
24+
# Install requirements.
25+
RUN yum makecache \
26+
&& yum -y install initscripts \
27+
&& yum -y update \
28+
&& yum -y install \
29+
sudo \
30+
which \
31+
hostname \
32+
python3 \
33+
&& yum clean all
34+
35+
# Install Ansible via Pip.
36+
RUN pip3 install --upgrade pip \
37+
&& pip3 install $pip_packages
38+
39+
# Disable requiretty.
40+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
41+
42+
# Install Ansible inventory file.
43+
RUN mkdir -p /etc/ansible
44+
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
45+
46+
VOLUME ["/sys/fs/cgroup"]
47+
CMD ["/usr/lib/systemd/systemd"]

docker/molecule/Dockerfile-ol8

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM oraclelinux:8
2+
LABEL maintainer="Thorsten Bruhns"
3+
# Original code is copied from:
4+
# https://raw.githubusercontent.com/geerlingguy/docker-ubi8-ansible/master/Dockerfile
5+
#
6+
ENV container=docker
7+
8+
ENV pip_packages "ansible"
9+
10+
# Silence annoying subscription messages.
11+
RUN echo "enabled=0" >> /etc/yum/pluginconf.d/subscription-manager.conf
12+
13+
# Install systemd -- See https://hub.docker.com/_/centos/
14+
RUN yum -y update; yum clean all; \
15+
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
16+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
17+
rm -f /etc/systemd/system/*.wants/*;\
18+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
19+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
20+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
21+
rm -f /lib/systemd/system/basic.target.wants/*;\
22+
rm -f /lib/systemd/system/anaconda.target.wants/*;
23+
24+
# Install requirements.
25+
RUN yum makecache --timer \
26+
&& yum -y install initscripts \
27+
&& yum -y update \
28+
&& yum -y install \
29+
sudo \
30+
which \
31+
hostname \
32+
python3 \
33+
&& yum clean all
34+
35+
# Install Ansible via Pip.
36+
RUN pip3 install --upgrade pip \
37+
&& pip3 install $pip_packages
38+
39+
# Disable requiretty.
40+
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
41+
42+
# Install Ansible inventory file.
43+
RUN mkdir -p /etc/ansible
44+
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
45+
46+
VOLUME ["/sys/fs/cgroup"]
47+
CMD ["/usr/lib/systemd/systemd"]

docker/molecule/build_container.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
set -eu
4+
5+
docker build -t ol8-ansible:latest -f Dockerfile-ol8 .
6+
docker build -t ol7-ansible:latest -f Dockerfile-ol7 .
7+
# SLES is not working with this container for ansible-oracle
8+
# => bci-base <> SLES ...
9+
# => not all needed RPMs are availible during installation
10+
# docker build -t registry.suse.com/bci/bci-base-ansible:15.3 -f Dockerfile-SLES15SP3 .
11+
# docker build -t registry.suse.com/bci/bci-base-ansible:15.4 -f Dockerfile-SLES15SP4 .
12+
# docker build -t registry.suse.com/bci/bci-base-ansible:15.5 -f Dockerfile-SLES15SP4 .
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
collections:
3+
# Use current directory as collection source
4+
- source: ./..
5+
type: dir
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Converge os
3+
ansible.builtin.import_playbook: opitzconsulting.ansible_oracle.os
4+
5+
- name: Converge swdb
6+
ansible.builtin.import_playbook: opitzconsulting.ansible_oracle.swdb
7+
vars:
8+
# install it directly from remote in this test
9+
# => Do not copy the installation media into container
10+
oracle_sw_copy: false
11+
is_sw_source_local: true
12+
oracle_stage_remote: /vagrant
13+
14+
- name: Converge sql_zauberkastern
15+
ansible.builtin.import_playbook: opitzconsulting.ansible_oracle.sql_zauberkastern
16+
17+
- name: Converge manage_db
18+
ansible.builtin.import_playbook: opitzconsulting.ansible_oracle.manage_db

0 commit comments

Comments
 (0)