Skip to content

Commit

Permalink
Using manual docker compose package install in puppet (#76)
Browse files Browse the repository at this point in the history
* Using more manual docker compose package install

* Docker version check

* Fix yaml typo

* Fixing paths pattern

* Fixing puppet-lint issues

* Fixing job paths globs

* Move RHEL specifics into RHEL case
  • Loading branch information
BrianSipos authored May 7, 2024
1 parent 19ce16d commit b97186b
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 198 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/anms-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
push:
paths:
- .github/workflows/anms-core.yaml
- deps
- anms-core
- deps/**
- anms-core/**

jobs:
unit-test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/aricodec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
push:
paths:
- .github/workflows/aricodec.yaml
- deps
- aricodec
- deps/**
- aricodec/**

jobs:
flake8:
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
ANMS_COMPOSE_OPTS: "-f docker-compose.yml -p anms"
AGENT_COMPOSE_OPTS: "-f agent-compose.yml -p agents"
steps:
- name: Versions
run: |
docker -v
docker ps
docker compose ls
- name: Checkout repository
uses: actions/checkout@v3
with:
Expand All @@ -28,17 +33,17 @@ jobs:
- name: Start
run: |
for OPTS_NAME in ANMS_COMPOSE_OPTS AGENT_COMPOSE_OPTS; do
docker-compose ${!OPTS_NAME} up --detach --force-recreate
docker compose ${!OPTS_NAME} up --detach --force-recreate
done
sleep 5
- name: Status
run: |
for BADSTATUS in stopped restarting; do
docker-compose ${ANMS_COMPOSE_OPTS} ps --services --filter status=${BADSTATUS} | tee -a /tmp/notgood
docker compose ${ANMS_COMPOSE_OPTS} ps --services --filter status=${BADSTATUS} | tee -a /tmp/notgood
done
# Show hints at what may be wrong
for SERVNAME in $(cat /tmp/notgood); do
docker-compose ${ANMS_COMPOSE_OPTS} logs --tail 50 ${SERVNAME}
docker compose ${ANMS_COMPOSE_OPTS} logs --tail 50 ${SERVNAME}
done
# Fail if any names are in the file
! grep '[^[:space:]]' /tmp/notgood
Expand All @@ -51,5 +56,5 @@ jobs:
if: always()
run: |
for OPTS_NAME in ANMS_COMPOSE_OPTS AGENT_COMPOSE_OPTS; do
docker-compose ${!OPTS_NAME} rm --stop --force
docker compose ${!OPTS_NAME} rm --stop --force
done
2 changes: 1 addition & 1 deletion .github/workflows/puppet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
paths:
- .github/workflows/puppet.yaml
- puppet
- puppet/**

jobs:
prep:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/transcoder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
push:
paths:
- .github/workflows/transcoder.yaml
- deps
- transcoder
- deps/**
- transcoder/**

jobs:
flake8:
Expand Down
129 changes: 0 additions & 129 deletions anms-ui/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ echo "Running docker-compose up"
ANMS_COMPOSE_OPTS="-f docker-compose.yml -p anms"
AGENT_COMPOSE_OPTS="-f agent-compose.yml -p agents"
for OPTS_NAME in ANMS_COMPOSE_OPTS AGENT_COMPOSE_OPTS; do
docker-compose ${!OPTS_NAME} up --detach
docker compose ${!OPTS_NAME} up --detach
done

if true; then
Expand All @@ -123,7 +123,7 @@ then
TMPFILE=$(mktemp)
for OPTS_NAME in ANMS_COMPOSE_OPTS AGENT_COMPOSE_OPTS; do
for BADSTATUS in stopped restarting; do
docker-compose ${!OPTS_NAME} ps --services --filter status=${BADSTATUS} | tee -a "${TMPFILE}"
docker compose ${!OPTS_NAME} ps --services --filter status=${BADSTATUS} | tee -a "${TMPFILE}"
done
done
# Show hints at what may be wrong
Expand Down
24 changes: 12 additions & 12 deletions puppet/Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
# The following directive installs modules to the managed moduledir.
moduledir '.modules'

mod 'simp/crypto_policy', '0.2.2'
mod 'simp/fips', '0.5.2'
mod 'puppetlabs/java_ks', '4.4.2'
mod 'puppetlabs/docker', '5.1.0'
mod 'simp/crypto_policy', '0.5.0'
mod 'simp/fips', '0.9.0'
mod 'puppetlabs/java_ks', '5.0.0'
mod 'puppetlabs/docker', '7.0.0'
mod 'puppetlabs/concat', '7.4.0'
mod 'puppetlabs/apt', '9.0.2'
mod 'puppet/trusted_ca', '4.1.0'
mod 'puppet/selinux', '3.4.1'
mod 'puppet/openssl', '2.0.1'
mod 'puppet/firewalld', '4.5.1'
mod 'puppetlabs/stdlib', '7.1.0'
mod 'simp/simplib', '4.10.4'
mod 'herculesteam/augeasproviders_grub', '3.2.0'
mod 'puppet/firewalld', '5.0.0'
mod 'puppetlabs/stdlib', '8.6.0'
mod 'simp/simplib', '4.12.2'
mod 'puppet/augeasproviders_grub', '5.1.0'
mod 'puppetlabs/powershell', '6.0.0'
mod 'puppetlabs/reboot', '4.3.1'
mod 'simp/simpkv', '0.8.0'
mod 'herculesteam/augeasproviders_core', '2.7.0'
mod 'puppetlabs/pwshlib', '0.10.3'
mod 'puppetlabs/reboot', '5.0.0'
mod 'simp/simpkv', '0.12.0'
mod 'puppet/augeasproviders_core', '4.1.0'
mod 'puppetlabs/pwshlib', '1.1.1'
2 changes: 0 additions & 2 deletions puppet/bolt-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ modules:
version_requirement: ">=9.0.0"
- name: puppetlabs/concat
version_requirement: ">=7.4.0 <8"
- name: puppetlabs/docker
version_requirement: ">=5.0.0"
- name: puppetlabs/java_ks
version_requirement: ">= 4.4.1"
- name: simp/fips
Expand Down
46 changes: 46 additions & 0 deletions puppet/modules/anms/manifests/docker.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Install docker and docker-compose according to upstream procedures at
# https://docs.docker.com/engine/install/rhel/#set-up-the-repository
# https://docs.docker.com/engine/install/rhel/#install-docker-engine
#
class anms::docker() {
case $facts['os']['family'] {
'RedHat': {
package { ['podman', 'runc']:
ensure => 'absent',
before => Package['docker-ce'],
}
package { 'yum-utils':
ensure => 'installed',
}
file { '/etc/yum.repos.d/docker.repo':
ensure => 'absent',
}
exec { 'yum-repo-docker-ce':
path => $facts['path'],
command => 'yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo',
creates => '/etc/yum.repos.d/docker-ce.repo',
require => Package['yum-utils'],
before => [Package['docker-ce'], Package['docker-buildx-plugin'], Package['docker-compose-plugin']],
}
}
default: {}
}

package { ['docker-ce', 'docker-ce-cli', 'containerd.io', 'docker-buildx-plugin', 'docker-compose-plugin']:
ensure => 'installed',
}
service { 'docker':
require => Package['docker-ce'],
}

file { '/usr/local/bin/docker-compose':
ensure => 'absent',
}
file { '/etc/docker/daemon.json':
source => 'puppet:///modules/anms/docker-daemon.json',
owner => 'root',
group => 'root',
mode => '0644',
notify => Service['docker'],
}
}
36 changes: 36 additions & 0 deletions puppet/modules/anms/manifests/docker_compose.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Define a docker compose project.
# The title of this resource is the project name.
#
# @param ensure The desired state of the project, if 'present' the containers are started each time puppet is run.
# @param compose_files The configuration files for this project.
# @param up_args Additional arguments for `docker compose ... up ...` command
#
define anms::docker_compose(
Enum['present','absent'] $ensure,
Array[String] $compose_files,
String $up_args = '',
) {
require anms::docker

$files_args = join($compose_files, ' ')
$is_running = "docker compose ls --filter \"name=${title}\" | tail --lines=+2 | grep running"

case $ensure {
'present': {
exec { "docker-compose-${title}-up":
path => $facts['path'],
command => "docker compose -p ${title} -f ${files_args} up --detach --remove-orphans ${up_args}",
}
}
'absent': {
exec { "docker-compose-${title}-up":
path => $facts['path'],
command => "docker compose -p ${title} -f ${files_args} rm --force --stop",
onlyif => $is_running,
}
}
default: {
fail("Invalid ensure argument: ${ensure}")
}
}
}
Loading

0 comments on commit b97186b

Please sign in to comment.