Skip to content

Commit 14425d1

Browse files
committed
Adds docker-compose support for testing purposes
* Previously working on this module required a buildout of a puppet infrastructure with VMs or cloud providers. Which can sometimes be costly or take hours to deploy. This commit uses containers and docker-compose to produce sample environments for each architecuture in order to perform rapid prototyping or test the functionality of this module and the puppet infra command. The architectures supported in this command are: * standard, stadard-ha * large, large-ha * extra-large, extra-large-ha While there are many other possiblites and combinations of amount of servers and containers these are the current choices. For more information please see documention/docker_examples.md
1 parent 763b877 commit 14425d1

29 files changed

+784
-1
lines changed

.fixtures.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ fixtures:
88
node_manager: 'https://github.com/WhatsARanjit/puppet-node_manager'
99
apply_helpers: 'https://github.com/puppetlabs/puppetlabs-apply_helpers'
1010
bolt_shim: 'https://github.com/puppetlabs/puppetlabs-bolt_shim'
11+
debug: 'https://github.com/nwops/puppet-debug'
1112
symlinks:
1213
"peadm": "#{source_dir}"

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
.rerun.json
28+
.rerun.json
29+
*.tar.gz

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.5

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ Reference:
2323
* [Classification](documentation/classification.md)
2424
* [Architectures](documentation/architectures.md)
2525
* [Testing](documentation/pre_post_checks.md)
26+
* [Docker Based Examples](documentation/docker_examples.md)

architectures/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# In order to run this with systemd you must do one of the following
2+
# use --privileged when running the container
3+
# mount the volume when running the container -v /sys/fs/cgroup:/sys/fs/cgroup:ro
4+
# docker run –privileged -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 2222:22
5+
FROM centos:7
6+
EXPOSE 22
7+
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
8+
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
9+
STOPSIGNAL SIGRTMIN+3
10+
RUN yum -y install systemd openssh openssh-server openssh-clients anacron sudo curl openssl; yum clean all;
11+
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
12+
rm -f /lib/systemd/system/multi-user.target.wants/*; \
13+
rm -f /etc/systemd/system/*.wants/*; \
14+
rm -f /lib/systemd/system/local-fs.target.wants/*; \
15+
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
16+
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
17+
rm -f /lib/systemd/system/basic.target.wants/*; \
18+
rm -f /lib/systemd/system/anaconda.target.wants/*; \
19+
rm -rf /var/cache/yum; \
20+
echo "root:test" | chpasswd; \
21+
useradd -m -s /bin/bash centos && echo "centos:test" | chpasswd; \
22+
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'
23+
VOLUME [ “/sys/fs/cgroup” ]
24+
CMD /sbin/init
25+
# ENTRYPOINT [ "/sbin/init" ]

architectures/Dockerfile_bolt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM puppet/puppet-bolt
2+
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
3+
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
4+
RUN apt-get update && apt-get install -y ssh sudo curl; \
5+
/opt/puppetlabs/bolt/bin/gem install bundler puppet-debugger -N -q
6+
CMD /bin/bash
7+
ENTRYPOINT [ "/opt/puppetlabs/bin/bolt" ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
version: "3"
2+
services:
3+
bolt:
4+
build:
5+
dockerfile: '../Dockerfile_bolt'
6+
context: .
7+
image: pe-bolt
8+
hostname: bolter.puppet.vm
9+
container_name: bolter.puppet.vm
10+
volumes:
11+
- .:/app
12+
working_dir: /app
13+
depends_on:
14+
- pe_xl_core_0
15+
compiler1:
16+
depends_on:
17+
- pe_xl_core_0
18+
build:
19+
dockerfile: '../Dockerfile'
20+
context: .
21+
entrypoint: /sbin/init
22+
image: pe-base
23+
privileged: true # required for systemd
24+
ports:
25+
- "22"
26+
- "8140"
27+
hostname: pe-xl-compiler-0.puppet.vm
28+
container_name: pe-xl-compiler-0.puppet.vm
29+
stop_signal: SIGRTMIN+3
30+
tmpfs:
31+
- /run
32+
- /tmp
33+
volumes:
34+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
35+
pe_pdb:
36+
depends_on:
37+
- pe_xl_core_0
38+
build:
39+
dockerfile: '../Dockerfile'
40+
context: .
41+
entrypoint: /sbin/init
42+
image: pe-base
43+
privileged: true # required for systemd
44+
ports:
45+
- "22"
46+
hostname: pe-xl-db-0.puppet.vm
47+
container_name: pe-xl-db-0.puppet.vm
48+
stop_signal: SIGRTMIN+3
49+
tmpfs:
50+
- /run
51+
- /tmp
52+
volumes:
53+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
54+
pe_pdb-replica:
55+
depends_on:
56+
- pe_xl_core_0
57+
build:
58+
dockerfile: '../Dockerfile'
59+
context: .
60+
entrypoint: /sbin/init
61+
image: pe-base
62+
privileged: true # required for systemd
63+
ports:
64+
- "22"
65+
hostname: pe-xl-db-1.puppet.vm
66+
container_name: pe-xl-db-1.puppet.vm
67+
stop_signal: SIGRTMIN+3
68+
tmpfs:
69+
- /run
70+
- /tmp
71+
volumes:
72+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
73+
pe_xl_core_1:
74+
depends_on:
75+
- pe_xl_core_0
76+
build:
77+
dockerfile: '../Dockerfile'
78+
context: .
79+
entrypoint: /sbin/init
80+
image: pe-base
81+
privileged: true # required for systemd
82+
ports:
83+
- "22"
84+
- "8140"
85+
- "8443"
86+
- "8080"
87+
- "8081"
88+
- "4433"
89+
- "443"
90+
container_name: pe-xl-core-1.puppet.vm
91+
hostname: pe-xl-core-1.puppet.vm
92+
stop_signal: SIGRTMIN+3
93+
tmpfs:
94+
- /run
95+
- /tmp
96+
volumes:
97+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
98+
pe_xl_core_0:
99+
build:
100+
dockerfile: '../Dockerfile'
101+
context: .
102+
entrypoint: /sbin/init
103+
image: pe-base
104+
privileged: true # required for systemd
105+
ports:
106+
- "22"
107+
- "8140"
108+
- "8443"
109+
- "8080"
110+
- "8081"
111+
- "4433"
112+
- "443"
113+
hostname: pe-xl-core-0.puppet.vm
114+
container_name: pe-xl-core-0.puppet.vm
115+
stop_signal: SIGRTMIN+3
116+
tmpfs:
117+
- /run
118+
- /tmp
119+
volumes:
120+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
groups:
3+
- name: puppet-enterprise-nodes
4+
config:
5+
transport: ssh
6+
ssh:
7+
tmpdir: /root
8+
script-dir: test123
9+
host-key-check: false
10+
user: root
11+
password: test
12+
tty: true
13+
targets:
14+
- pe-xl-compiler-0.puppet.vm
15+
- pe-xl-db-0.puppet.vm
16+
- pe-xl-db-1.puppet.vm
17+
- pe-xl-core-0.puppet.vm
18+
- pe-xl-core-1.puppet.vm
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"master_host": "pe-xl-core-0.puppet.vm",
3+
"puppetdb_database_host": "pe-xl-db-0.puppet.vm",
4+
"puppetdb_database_replica_host": "pe-xl-db-1.puppet.vm",
5+
"master_replica_host": "pe-xl-core-1.puppet.vm",
6+
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
7+
"console_password": "puppetlabs",
8+
"dns_alt_names": [ "puppet", "pe-xl-core-0.puppet.vm", "puppet-xl.vm" ],
9+
"version": "2019.1.1",
10+
"compiler_pool_address": "puppet-xl.vm",
11+
"stagingdir": "/downloads"
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"master_host": "pe-xl-core-0.puppet.vm",
3+
"puppetdb_database_host": "pe-xl-db-0.puppet.vm",
4+
"puppetdb_database_replica_host": "pe-xl-db-1.puppet.vm",
5+
"master_replica_host": "pe-xl-core-1.puppet.vm",
6+
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
7+
"version": "2019.5.0",
8+
"stagingdir": "/downloads"
9+
}
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
version: "3"
2+
services:
3+
bolt:
4+
build:
5+
dockerfile: '../Dockerfile_bolt'
6+
context: .
7+
image: pe-build
8+
hostname: bolter.puppet.vm
9+
container_name: bolter.puppet.vm
10+
volumes:
11+
- .:/app
12+
working_dir: /app
13+
depends_on:
14+
- pe_xl_core
15+
compiler1:
16+
depends_on:
17+
- pe_xl_core
18+
build:
19+
dockerfile: '../Dockerfile'
20+
context: .
21+
entrypoint: /sbin/init
22+
image: pe-base
23+
privileged: true # required for systemd
24+
ports:
25+
- "22"
26+
- "8140"
27+
hostname: pe-xl-compiler-0.puppet.vm
28+
container_name: pe-xl-compiler-0.puppet.vm
29+
stop_signal: SIGRTMIN+3
30+
tmpfs:
31+
- /run
32+
- /tmp
33+
volumes:
34+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
35+
pe_pdb:
36+
depends_on:
37+
- pe_xl_core
38+
build:
39+
dockerfile: '../Dockerfile'
40+
context: .
41+
entrypoint: /sbin/init
42+
image: pe-base
43+
privileged: true # required for systemd
44+
ports:
45+
- "22"
46+
hostname: pe-xl-db-0.puppet.vm
47+
container_name: pe-xl-db-0.puppet.vm
48+
stop_signal: SIGRTMIN+3
49+
tmpfs:
50+
- /run
51+
- /tmp
52+
volumes:
53+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
54+
pe_xl_core:
55+
build:
56+
dockerfile: '../Dockerfile'
57+
context: .
58+
entrypoint: /sbin/init
59+
image: pe-base
60+
privileged: true # required for systemd
61+
ports:
62+
- "22"
63+
- "8140"
64+
- "8443"
65+
- "8080"
66+
- "8081"
67+
- "4433"
68+
- "443"
69+
hostname: pe-xl-core-0.puppet.vm
70+
container_name: pe-xl-core-0.puppet.vm
71+
stop_signal: SIGRTMIN+3
72+
tmpfs:
73+
- /run
74+
- /tmp
75+
volumes:
76+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
groups:
3+
- name: puppet-enterprise-nodes
4+
config:
5+
transport: ssh
6+
ssh:
7+
tmpdir: /root
8+
script-dir: test123
9+
host-key-check: false
10+
user: root
11+
password: test
12+
tty: true
13+
targets:
14+
- pe-xl-compiler-0.puppet.vm
15+
- pe-xl-db-0.puppet.vm
16+
- pe-xl-core-0.puppet.vm

architectures/extra-large/params.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"master_host": "pe-xl-core-0.puppet.vm",
3+
"puppetdb_database_host": "pe-xl-db-0.puppet.vm",
4+
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
5+
"console_password": "puppetlabs",
6+
"dns_alt_names": [ "puppet", "pe-xl-core.puppet.vm" ],
7+
"version": "2019.1.1",
8+
"stagingdir": "/downloads"
9+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
# bundle install
3+
# bundle exec rake spec_prep
4+
# must be in the architectures/standard directory
5+
docker-compose up --build -d
6+
downloads=$(realpath ../)
7+
mod_path=$(realpath ../../) # required due to symlink in fixtures
8+
docker-compose run -v ${downloads}:/downloads -v ${mod_path}/spec/fixtures/modules:/modules -v ${mod_path}:/mods/peadm bolt plan run peadm::provision \
9+
--inventory inventory.yaml \
10+
--modulepath=/modules:/mods \
11+
--params @params.json
12+
13+
# There is an issue with the password not being set correctly
14+
# docker-compose exec standard_aio puppet infra console_password --password puppetlabs

0 commit comments

Comments
 (0)