Skip to content

Commit 1622d61

Browse files
authored
Merge pull request #98 from nwops/docker_updates
Docker updates
2 parents 0aed3c8 + 56c3444 commit 1622d61

File tree

13 files changed

+106
-18
lines changed

13 files changed

+106
-18
lines changed

Diff for: .sync.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
---
2+
Gemfile:
3+
':development':
4+
required:
5+
- gem: 'puppet-debugger'
6+
version: '>= 0.18.0'
27
Rakefile:
38
extras:
49
- 'PuppetSyntax.exclude_paths = ["plans/**/*.pp", "vendor/**/*"]'
510
.gitignore:
611
paths:
712
- '.rerun.json'
813
- '*.tar.gz'
9-
14+

Diff for: Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
1717
minor_version = ruby_version_segments[0..1].join('.')
1818

1919
group :development do
20+
gem 'puppet-debugger', '0.18.0'
2021
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
2122
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
2223
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Plans:
1717
* [Provision](documentation/provision.md)
1818
* [Upgrade](documentation/upgrade.md)
1919
* [Convert](documentation/convert.md)
20+
* [Status](documentation/status.md)
2021

2122
Reference:
2223

Diff for: documentation/docker_examples.md

+48
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,54 @@ This will run an interactive bash shell in the running container.
6969
### Upgrades
7070
There is also a upgrade.sh script that is similar to the provision.sh script. This script will upgrade an already provisioned PE stack to the version specified in the update_params.json file.
7171
72+
## Attaching agent containers
73+
Because we are using containers we can start up numerous container instances and attach them all to the same PE stack. In a matter of minutes you can easily attach hunders of new nodes to the PE stack (if resources allow). This is very useful for testing out scenarios involving different puppet versions or operating systems and even features like the orchestrator.
74+
75+
To attach a container to the PE stack you first must get the network name of the PE stack. This can be done with a command like: `docker inspect pe-xl-core-0.puppet.vm`. You need to use either the container id or the container name of the MoM when inspecting.
76+
77+
The network name we want to grab is 'extra-large-ha_default'. (Yours will be different, but the output will be similar)
78+
79+
```shell
80+
docker inspect pe-xl-core-0.puppet.vm -f "{{json .NetworkSettings.Networks }}" | jq
81+
{
82+
"extra-large-ha_default": {
83+
"IPAMConfig": null,
84+
"Links": null,
85+
"Aliases": [
86+
"pe_xl_core_0",
87+
"5cf7047a36cd"
88+
],
89+
"NetworkID": "204ae562a25510b2425f9fe3f1599c487e40dbcaaaaf02c2f73f6fa81f45d674",
90+
"EndpointID": "d91d7060fcc623a9f16cea09eecf83e9ee4454252e1af34053ef090f9c01c9c3",
91+
"Gateway": "172.25.0.1",
92+
"IPAddress": "172.25.0.6",
93+
"IPPrefixLen": 16,
94+
"IPv6Gateway": "",
95+
"GlobalIPv6Address": "",
96+
"GlobalIPv6PrefixLen": 0,
97+
"MacAddress": "02:42:ac:19:00:06",
98+
"DriverOpts": null
99+
}
100+
}
101+
```
102+
103+
**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`.
104+
105+
### Starting agent containers
106+
Once you have the network name you only need to specify the network when starting a container. Puppet [publishes container images](https://hub.docker.com/r/puppet/puppet-agent) for all version of the puppet agent. So you can easily switch agent versions with a single command. Which container image you use is entirely up to you. If it doesn't have puppet preinstalled you can use the special curl command from the PE console to install it.
107+
108+
Example:
109+
`docker run -ti --network=extra-large-ha_default --entrypoint=/bin/bash puppet/puppet-agent:latest`
110+
`docker run -ti --network=extra-large-ha_default --entrypoint=/bin/bash puppet/puppet-agent:6.15.0`
111+
`docker run -ti --network=extra-large-ha_default --entrypoint=/bin/bash puppet/puppet-agent:6.3.0`
112+
`docker run -ti --network=extra-large-ha_default --entrypoint=/bin/bash ruby:latest`
113+
114+
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
115+
there is no need for containers with systemd.
116+
117+
At this time we have not added documention for starting a container with systemd. Instructions coming soon.
118+
119+
72120
### Other notes
73121
1. The provision plan is not fully idempotent.
74122
2. Some tasks may fail when run due to resource constraints.

Diff for: spec/docker/Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == system
2626
rm -rf /var/cache/yum; \
2727
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service' && \
2828
ln -s '/etc/systemd/system/live_audit.service' '/etc/systemd/system/multi-user.target.wants/live_audit.service'
29+
ARG HOST="localhost"
30+
RUN mkdir -p /root/.puppetlabs/client-tools && \
31+
echo $' \n\
32+
{ \n\
33+
"puppetdb": { \n\
34+
"server_urls": "https://'$HOST$':8081", \n\
35+
"cacert": "/etc/puppetlabs/puppet/ssl/certs/ca.pem", \n\
36+
"cert": "/etc/puppetlabs/puppet/ssl/certs/'$HOST$'.pem", \n\
37+
"key": "/etc/puppetlabs/puppet/ssl/private_keys/'$HOST$'.pem" \n\
38+
} \n\
39+
} \n '\
40+
> /root/.puppetlabs/client-tools/puppetdb.conf
2941
VOLUME [ “/sys/fs/cgroup” ]
3042
#CMD /bin/bash
3143
ENTRYPOINT [ "/sbin/init" ]

Diff for: spec/docker/Dockerfile_bolt

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
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; \
2+
RUN apt-get update && apt-get install -y locales ssh sudo curl; \
53
/opt/puppetlabs/bolt/bin/gem install bundler puppet-debugger -N -q
4+
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
5+
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment && \
6+
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
7+
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
8+
locale-gen en_US.UTF-8
69
CMD /bin/bash
710
ENTRYPOINT [ "/opt/puppetlabs/bin/bolt" ]

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

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
depends_on:
1414
- pe_xl_core_0
1515
compiler1:
16+
restart: always
1617
depends_on:
1718
- pe_xl_core_0
1819
build:
@@ -33,6 +34,7 @@ services:
3334
volumes:
3435
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
3536
pe_pdb:
37+
restart: always
3638
depends_on:
3739
- pe_xl_core_0
3840
build:
@@ -52,6 +54,7 @@ services:
5254
volumes:
5355
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
5456
pe_pdb-replica:
57+
restart: always
5558
depends_on:
5659
- pe_xl_core_0
5760
build:
@@ -71,11 +74,14 @@ services:
7174
volumes:
7275
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
7376
pe_xl_core_1:
77+
restart: always
7478
depends_on:
7579
- pe_xl_core_0
7680
build:
7781
dockerfile: 'Dockerfile'
7882
context: ../
83+
args:
84+
HOST: 'pe-xl-core-1.puppet.vm'
7985
entrypoint: /sbin/init
8086
image: pe-base
8187
privileged: true # required for systemd
@@ -96,9 +102,12 @@ services:
96102
volumes:
97103
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
98104
pe_xl_core_0:
105+
restart: always
99106
build:
100107
dockerfile: 'Dockerfile'
101108
context: ../
109+
args:
110+
HOST: 'pe-xl-core-0.puppet.vm'
102111
entrypoint: /sbin/init
103112
image: pe-base
104113
privileged: true # required for systemd

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

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ services:
5555
build:
5656
dockerfile: 'Dockerfile'
5757
context: ../
58+
args:
59+
HOST: 'pe-xl-core-0.puppet.vm'
5860
entrypoint: /sbin/init
5961
image: pe-base
6062
privileged: true # required for systemd

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

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ services:
3838
build:
3939
dockerfile: 'Dockerfile'
4040
context: ../
41+
args:
42+
HOST: 'pe-lg-replica.puppet.vm'
4143
entrypoint: /sbin/init
4244
image: pe-base
4345
privileged: true # required for systemd
@@ -61,6 +63,8 @@ services:
6163
build:
6264
dockerfile: 'Dockerfile'
6365
context: ../
66+
args:
67+
HOST: 'pe-lg.puppet.vm'
6468
entrypoint: /sbin/init
6569
image: pe-base
6670
privileged: true # required for systemd

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

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ services:
3636
build:
3737
dockerfile: 'Dockerfile'
3838
context: ../
39+
args:
40+
HOST: 'pe-lg.puppet.vm'
3941
entrypoint: /sbin/init
4042
image: pe-base
4143
privileged: true # required for systemd

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

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818
build:
1919
dockerfile: 'Dockerfile'
2020
context: ../
21+
args:
22+
HOST: 'pe-std-replica.puppet.vm'
2123
entrypoint: /sbin/init
2224
image: pe-base
2325
privileged: true # required for systemd
@@ -41,6 +43,8 @@ services:
4143
build:
4244
dockerfile: 'Dockerfile'
4345
context: ../
46+
args:
47+
HOST: 'pe-std.puppet.vm'
4448
entrypoint: /sbin/init
4549
image: pe-base
4650
privileged: true # required for systemd

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

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ services:
2020
build:
2121
dockerfile: 'Dockerfile'
2222
context: ../
23+
args:
24+
HOST: 'pe-std.puppet.vm'
2325
entrypoint: /sbin/init
2426
image: pe-base
2527
privileged: true # required for systemd

Diff for: tasks/submit_csr.rb

+9-14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#
55
require 'json'
66
require 'open3'
7+
require 'puppet'
8+
require 'puppet/face'
9+
10+
Puppet.initialize_settings
711

812
def already_signed?
913
cmd = ['/opt/puppetlabs/bin/puppet', 'ssl', 'verify']
@@ -12,23 +16,14 @@ def already_signed?
1216
end
1317

1418
def main
15-
majver = `/opt/puppetlabs/bin/puppet --version`
16-
.chomp
17-
.split('.')
18-
.first
19-
.to_i
20-
19+
majver = Gem::Version.new(Puppet.version).segments.first
2120
if majver < 6
22-
conf = `/opt/puppetlabs/bin/puppet config print dns_alt_names certname`
23-
.chomp
24-
.split("\n")
25-
.map { |line| line.split(' = ', 2) }
26-
.to_h
27-
21+
# signed cert already exist, assuming it is valid, no good way to verify until Puppet 6
22+
exit 0 if File.exist?(Puppet.settings[:hostcert])
2823
cmd = ['/opt/puppetlabs/bin/puppet', 'certificate', 'generate',
2924
'--ca-location', 'remote',
30-
'--dns-alt-names', conf['dns_alt_names'],
31-
conf['certname']]
25+
'--dns-alt-names', Puppet.settings[:dns_alt_names],
26+
Puppet.settings[:certname]]
3227
else
3328
exit 0 if already_signed?
3429
cmd = ['/opt/puppetlabs/bin/puppet', 'ssl', 'submit_request']

0 commit comments

Comments
 (0)