-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using manual docker compose package install in puppet (#76)
* 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
1 parent
19ce16d
commit b97186b
Showing
13 changed files
with
129 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ on: | |
push: | ||
paths: | ||
- .github/workflows/puppet.yaml | ||
- puppet | ||
- puppet/** | ||
|
||
jobs: | ||
prep: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") | ||
} | ||
} | ||
} |
Oops, something went wrong.