Skip to content

Commit e5e0d61

Browse files
authored
Merge pull request #224 from nwops/docker_fix
Updates docker to use bolt commands
2 parents 95e4cd9 + abfd2b8 commit e5e0d61

30 files changed

+269
-112
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@
3232
.plan_cache.json
3333
.resource_types/
3434
bolt-debug.log
35+
spec/docker/**/*.tar.gz
36+
spec/docker/**/*.asc
37+
spec/docker/**/files/puppet-enterprise*
38+
spec/docker/.task_cache.json

Diff for: documentation/docker_examples.md

+38-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
## Docker Based Examples
22
This module provides docker compose files for the various architectures for experimentation purposes. This gives you the ability to stand up an entire PE stack in order to learn how this module and DR works. If you have docker and docker-compose you can start up a full Puppet architecture with a single command. Please note that Puppet does not support PE on containers in production.
33

4-
In order to decouple Bolt from a dev system, a special bolt container is created that will run all the bolt commands. This is
5-
required to achieve maximum portability. Should you want to run bolt commands against the PE stack you must
6-
first login to this bolt container via ssh, docker or docker-compose.
7-
8-
Example: `docker-compose run --entrypoint=/bin/bash bolt`
9-
104
### Requirements
115
To run the container based examples you will need the following requirements:
126

137
1. Docker
148
2. Docker compose
9+
3. Bolt 3.18+
1510
3. realpath (brew install coreutils on mac)
1611
4. 16GB memory, 24GB+ for XL and XL-DR architectures
1712
5. CPU with many cores (Tested with Core i7 6700)
@@ -46,6 +41,8 @@ In order to stop and remove the containers you will need to perform the followin
4641
2. `cd <chosen architecture>`
4742
3. docker-compose down
4843

44+
Alternative you can run something similar like: `docker-compose --project-directory=large down`
45+
4946
### Logging into the console
5047
You can login to the PE Console after successful install. However, first you will need to
5148
grab the mapped port number of the PE console. The port numbers are mapped dynamically as to not
@@ -108,6 +105,8 @@ docker inspect pe-xl-core-0.puppet.vm -f "{{json .NetworkSettings.Networks }}" |
108105
}
109106
```
110107

108+
You can also run `docker inspect pe-xl-core-0.puppet.vm -f "{{json .HostConfig.NetworkMode }}" | sed -e 's/^"//' -e 's/"$//'`
109+
111110
**NOTE** In these example you may see the use of `jq`. This is a [cli utility for parsing JSON](https://stedolan.github.io/jq/). I recommend installing it. As a alternative you can pipe output to `python -m json.tool`.
112111

113112
### Starting agent containers
@@ -122,8 +121,38 @@ Example:
122121
For most tasks these images are great. However, if you wish to use puppet orchestrator with the pcp transport. The one requirement is that all images used must be systemd aware, otherwise pxp will not start. If you do not plan on using pcp
123122
there is no need for containers with systemd.
124123

125-
At this time we have not added documention for starting a container with systemd. Instructions coming soon.
124+
You can use the the custom image `pe-base` built with the docker cluster named pe-base. This is a centos:7 image that you can use to generate tens or hundreds of agents. (Resources permitting). You will also want to run the docker run command with additonal flags.
125+
126+
`docker run -d -t --hostname=pe-std-agent1.puppet.vm --network=pe-std_default --privileged --label=pe-std-agent,docker-example-agent" -v /sys/fs/cgroup:/sys/fs/cgroup:ro pe-base"`
127+
128+
Once you have created the container you will obviously want to install the puppet agent
129+
130+
`docker exec -ti $CONTAINER_ID sh -c "curl -k https://${PE_SERVER}:8140/packages/current/install.bash | bash && puppet agent -t"`
131+
132+
Accept the cert in the console and run the puppet agent again on the agent container.
126133

134+
Login interactively if you wish: `docker exec -ti $CONTAINER_ID /bin/bash`
135+
136+
Take a look at the spec/docker/Dockerfile for examples of how to setup systemd in a container.
137+
138+
139+
### Cleaning up
140+
Before you run docker-compose down inside the cluster type directory you will need to stop and remove
141+
all the agent containers if created.
142+
143+
This can be done like so:
144+
145+
```bash
146+
# base name is the name of the primary hostname without domain
147+
PE_CLUSTER_TYPE=standard
148+
BASE_NAME=pe-std
149+
docker stop $(docker ps -q -f label="${BASE_NAME}-agent")
150+
docker rm $(docker ps -a -q -f label="${BASE_NAME}-agent")
151+
# The docker-compose down command cannot be run until the agents have been removed
152+
cd spec/docker/${PE_CLUSTER_TYPE}
153+
docker-compose down
154+
155+
```
127156

128157
### Other notes
129158
1. The install plan is not fully idempotent.
@@ -134,3 +163,5 @@ At this time we have not added documention for starting a container with systemd
134163
6. You can use top to view all the processes being run in the containers.
135164
7. Docker will use the privilege mode option when running these examples (systemd support)
136165
8. Systemd is running inside these containers! The real systemd, not the fake one.
166+
167+
If you see errors regarding peadmin::puppet_runonce, just run the install or upgrade script again. Might have to perform multiple times for resource constrained docker hosts.

Diff for: spec/docker/.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.tar.gz
2+
puppet-enterprise*

Diff for: spec/docker/Dockerfile

+9-10
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
FROM centos:7
66
EXPOSE 22
77
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
8+
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
99
STOPSIGNAL SIGRTMIN+3
10-
ADD live_audit.sh /usr/bin/live_audit.sh
11-
ADD live_audit.service /etc/systemd/system/live_audit.service
12-
RUN chmod 644 /etc/systemd/system/live_audit.service && chmod 755 /usr/bin/live_audit.sh && \
13-
echo "root:test" | chpasswd; \
14-
useradd -m -s /bin/bash centos && echo "centos:test" | chpasswd;
15-
RUN yum -y install epel-release systemd rsync tree vim openssh openssh-server openssh-clients anacron sudo curl openssl
16-
RUN yum -y install inotify-tools && mkdir /root/bolt_scripts && yum clean all
10+
RUN echo "root:test" | chpasswd && \
11+
useradd -m -s /bin/bash centos && echo "centos:test" | chpasswd;
12+
RUN yum -y install wget systemd rsync tree vim openssh openssh-server openssh-clients anacron sudo curl openssl
13+
RUN yum remove -y puppet-agent # remove any old puppet-agent
14+
COPY pe-old-pub.gpg /tmp
15+
RUN mkdir /root/bolt_scripts && yum clean all && \
16+
gpg --import /tmp/pe-old-pub.gpg
1717
# remove any scripts that don't need to be run
1818
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
1919
rm -f /lib/systemd/system/multi-user.target.wants/*; \
@@ -24,8 +24,7 @@ RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == system
2424
rm -f /lib/systemd/system/basic.target.wants/*; \
2525
rm -f /lib/systemd/system/anaconda.target.wants/*; \
2626
rm -rf /var/cache/yum; \
27-
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service' && \
28-
ln -s '/etc/systemd/system/live_audit.service' '/etc/systemd/system/multi-user.target.wants/live_audit.service'
27+
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'
2928
ARG HOST="localhost"
3029
RUN mkdir -p /root/.puppetlabs/client-tools && \
3130
echo $' \n\

Diff for: spec/docker/Puppetfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This Puppetfile is managed by Bolt. Do not edit.
2+
# For more information, see https://pup.pt/bolt-modules
3+
4+
# The following directive installs modules to the managed moduledir.
5+
moduledir '.modules'
6+
7+
mod 'puppet/format', '1.0.0'
8+
mod 'puppetlabs/bolt_shim', '0.3.2'
9+
mod 'puppetlabs/apply_helpers', '0.3.0'
10+
mod 'WhatsARanjit/node_manager', '0.7.5'
11+
mod 'puppetlabs/ruby_task_helper', '0.5.1'
12+
mod 'puppetlabs/stdlib', '7.1.0'
13+
mod 'nwops/container_inventory', '0.1.1'

Diff for: spec/docker/bolt-project.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: peadm_docker_examples
3+
modules:
4+
- name: nwops/container_inventory
5+
version_requirement: ">= 0.1.1"
6+
- name: puppetlabs/stdlib
7+
version_requirement: ">= 6.5.0 < 8.0.0"
8+
- puppetlabs/ruby_task_helper
9+
- WhatsARanjit/node_manager
10+
- puppetlabs/apply_helpers
11+
- puppetlabs/bolt_shim
12+
- puppet/format

Diff for: spec/docker/extra-large-ha/docker-compose.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ services:
6666
- /run
6767
- /tmp
6868
volumes:
69-
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
69+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
70+
71+
7072
pe_xl_core_1:
7173
restart: always
7274
depends_on:
@@ -96,7 +98,9 @@ services:
9698
- /run
9799
- /tmp
98100
volumes:
99-
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
101+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
102+
103+
100104
pe_xl_core_0:
101105
restart: always
102106
build:
@@ -124,4 +128,6 @@ services:
124128
- /run
125129
- /tmp
126130
volumes:
127-
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
131+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
132+
133+

Diff for: spec/docker/extra-large-ha/params.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
"primary_postgresql_host": "pe-xl-db-0.puppet.vm",
44
"replica_postgresql_host": "pe-xl-db-1.puppet.vm",
55
"replica_host": "pe-xl-core-1.puppet.vm",
6-
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
6+
"compiler_hosts": [
7+
"pe-xl-compiler-0.puppet.vm"
8+
],
79
"console_password": "puppetlabs",
8-
"dns_alt_names": [ "puppet", "pe-xl-core-0.puppet.vm", "puppet-xl.vm" ],
10+
"dns_alt_names": [
11+
"puppet",
12+
"pe-xl-core-0.puppet.vm",
13+
"puppet-xl.vm"
14+
],
915
"version": "2019.8.5",
1016
"compiler_pool_address": "puppet-xl.vm"
1117
}

Diff for: spec/docker/extra-large-ha/upgrade_params.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
2-
"primary_host": "pe-xl-core-0.puppet.vm",
3-
"primary_postgresql_host": "pe-xl-db-0.puppet.vm",
4-
"replica_postgresql_host": "pe-xl-db-1.puppet.vm",
5-
"replica_host": "pe-xl-core-1.puppet.vm",
6-
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
7-
"version": "2019.8.5"
2+
"primary_host": "pe-xl-core-0.puppet.vm",
3+
"primary_postgresql_host": "pe-xl-db-0.puppet.vm",
4+
"replica_postgresql_host": "pe-xl-db-1.puppet.vm",
5+
"replica_host": "pe-xl-core-1.puppet.vm",
6+
"compiler_hosts": [
7+
"pe-xl-compiler-0.puppet.vm"
8+
],
9+
"version": "2019.8.5"
810
}

Diff for: spec/docker/extra-large/docker-compose.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@ services:
6969
- /run
7070
- /tmp
7171
volumes:
72-
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
72+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
73+
74+

Diff for: spec/docker/extra-large/params.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"primary_host": "pe-xl-core-0.puppet.vm",
33
"primary_postgresql_host": "pe-xl-db-0.puppet.vm",
4-
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
4+
"compiler_hosts": [
5+
"pe-xl-compiler-0.puppet.vm"
6+
],
57
"console_password": "puppetlabs",
6-
"dns_alt_names": [ "puppet", "pe-xl-core-0.puppet.vm" ],
8+
"dns_alt_names": [
9+
"puppet",
10+
"pe-xl-core-0.puppet.vm"
11+
],
712
"version": "2019.8.5"
813
}

Diff for: spec/docker/extra-large/upgrade_params.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"primary_host": "pe-xl-core-0.puppet.vm",
33
"primary_postgresql_host": "pe-xl-db-0.puppet.vm",
44
"compiler_hosts": ["pe-xl-compiler-0.puppet.vm"],
5-
"version": "2019.8.5"
5+
"version": "2019.8.5"
66
}

Diff for: spec/docker/install.sh

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
#!/usr/bin/env bash
2-
# bundle install or pdk bundle install
3-
# bundle exec rake spec_prep or pdk bundle exec rake spec_prep
42
# must be in the spec/docker directory
5-
echo 'Please choose a PE architecture to provision: '
3+
# must have bolt 3.18+ installed
64
downloads=$(realpath ./)
75
inventory_dir=$(realpath ./)
86
inventory_path=${inventory_dir}/inventory.yaml
97
base_repo=$(realpath ../../)
108
spec_path=$(realpath ../)
11-
fixtures_path=$spec_path/fixtures/modules
12-
num=$(ls ${fixtures_path} | wc -l)
13-
if [[ ! "$num" -gt "8" ]]; then
14-
echo "No fixtures, please run bundle exec rake spec_prep or pdk bundle exec rake spec_prep"
15-
exit 1
16-
fi
9+
bolt module install
10+
ln -nfs ../../../ ./.modules/peadm
1711
# The concurrency is set to 2 to keep CPU usage from skyrocketing during Large and XL deployments
12+
echo 'Please choose a PE architecture to provision: '
13+
1814
select opt in */
1915
do
2016
dir=$(realpath ${opt})
2117
name=$(basename $opt)
2218
cd $dir
2319
docker-compose up -d --build
24-
# nohup /usr/bin/live_audit.sh /root/bolt_scripts /tmp/backup &
25-
pdk bundle exec bolt plan run peadm::install --concurrency 2 \
20+
bolt plan run peadm::install --concurrency 2 \
2621
--inventory $inventory_path \
27-
--modulepath=$fixtures_path \
2822
--params @${dir}/params.json \
2923
--targets=$name
3024
break;
3125
done
26+
# --modulepath=./modules \

Diff for: spec/docker/large-ha/docker-compose.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ services:
5050
- /run
5151
- /tmp
5252
volumes:
53-
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
53+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
54+
5455
large_aio:
5556
build:
5657
dockerfile: 'Dockerfile'
@@ -78,3 +79,5 @@ services:
7879
- /tmp
7980
volumes:
8081
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
82+
83+

Diff for: spec/docker/large-ha/params.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"primary_host": "pe-lg.puppet.vm",
33
"replica_host": "pe-lg-replica.puppet.vm",
4-
"compiler_hosts": ["pe-lg-compiler-0.puppet.vm"],
4+
"compiler_hosts": [
5+
"pe-lg-compiler-0.puppet.vm"
6+
],
57
"console_password": "puppetlabs",
6-
"dns_alt_names": [ "puppet", "pe-lg.puppet.vm" ],
8+
"dns_alt_names": [
9+
"puppet",
10+
"pe-lg.puppet.vm"
11+
],
712
"version": "2019.8.5"
813
}

Diff for: spec/docker/large-ha/upgrade_params.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"primary_host": "pe-lg.puppet.vm",
3-
"replica_host": "pe-lg-replica.puppet.vm",
4-
"compiler_hosts": ["pe-lg-compiler-0.puppet.vm"],
5-
"version": "2019.8.5"
2+
"primary_host": "pe-lg.puppet.vm",
3+
"replica_host": "pe-lg-replica.puppet.vm",
4+
"compiler_hosts": [
5+
"pe-lg-compiler-0.puppet.vm"
6+
],
7+
"version": "2019.8.5"
68
}
7-

Diff for: spec/docker/large/docker-compose.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ services:
4848
- /run
4949
- /tmp
5050
volumes:
51-
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
51+
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
52+

Diff for: spec/docker/large/params.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"primary_host": "pe-lg.puppet.vm",
3-
"compiler_hosts": ["pe-lg-compiler-0.puppet.vm"],
3+
"compiler_hosts": [
4+
"pe-lg-compiler-0.puppet.vm"
5+
],
46
"console_password": "puppetlabs",
5-
"dns_alt_names": [ "puppet", "pe-lg.puppet.vm" ],
6-
"version": "2019.8.5"
7+
"dns_alt_names": [
8+
"puppet",
9+
"pe-lg.puppet.vm"
10+
],
11+
"version": "2019.8.1"
712
}

Diff for: spec/docker/large/upgrade_params.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"primary_host": "pe-lg.puppet.vm",
3-
"compiler_hosts": ["pe-lg-compiler-0.puppet.vm"],
4-
"version": "2019.8.5"
2+
"primary_host": "pe-lg.puppet.vm",
3+
"compiler_hosts": [
4+
"pe-lg-compiler-0.puppet.vm"
5+
],
6+
"version": "2019.8.8"
57
}
6-

Diff for: spec/docker/live_audit.service

-8
This file was deleted.

0 commit comments

Comments
 (0)