Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Could not find a suitable provider for docker_compose #742

Closed
marrajo-afk opened this issue Apr 15, 2021 · 11 comments
Closed

Error: Could not find a suitable provider for docker_compose #742

marrajo-afk opened this issue Apr 15, 2021 · 11 comments

Comments

@marrajo-afk
Copy link

Describe the Bug

When use classes docker and docker::compose in an own class (lamp) , the first puppet agent execution failed with:
Error: Could not find a suitable provider for docker_compose

It only works when the docker-ce package is installed manually in the node before the first puppet agent is run in it.

lamp/init.pp:
include docker
include docker::compose

Class['docker::compose'] ->
Class['docker'] ->
File['docker-compose'] ->
Docker_compose['lamp']

file { "docker-compose":
name => "/var/pr1/docker-compose.yml",
replace => true,
content => template("lamp/docker-compose.erb"),
notify => Docker_Compose['lamp']
}
docker_compose { 'lamp':
compose_files => ['/var/pr1//docker-compose.yml'],
ensure => present,
}

If i change the order of execution, the result is the same, i.e:
Class['docker'] ->
Class['docker::compose'] ->
....
....

docker/manifest/params.pp:
$compose_install_path = '/usr/bin'
$compose_version = '1.29.1'

After the failed execution, both docker-compose executable and docker-ce packages are correctly installed

Expected Behavior

Correct execution of docker_compose Resource Type

Environment

Puppet master:
Foreman 2.2
Debian 10
module puppetlabs-docker (v4.0.0)
Puppet v7.5.0

Agent:
Debian10
Puppet v7.5.0

Thanks.

@benh57
Copy link

benh57 commented May 2, 2021

Also seeing this, seems the provider doesnt use the full path to docker-compose, which is in /usr/local/bin. (when managed by this module), but /usr/local/bin is not in the default PATH for puppet on my servers.

@hugoboos
Copy link

Same here. Using version 3.14.0 of the module with Puppet version 5.5.22.

@hugoboos
Copy link

Quick fix by linking docker-compose to /usr/bin.

class { '::docker::compose':
  ensure  => present,
  version => '1.29.2',
}

file { '/usr/bin/docker-compose':
  ensure  => link,
  target  => '/usr/local/bin/docker-compose',
  require => Class['::docker::compose'],
}

docker_compose { 'test':
  ...
  require => File['/usr/bin/docker-compose'],
}

@marrajo-afk
Copy link
Author

marrajo-afk commented May 26, 2021

I force the docker-compose path in docker/manifest/params.pp as:
$compose_install_path = '/usr/bin'
$compose_version = '1.29.1'

After (failed) applying catalog:
$ which docker-compose
/usr/bin/docker-compose

It seems that only works when docker-ce is installed previously manually (before executing puppet agent --test)

@markri
Copy link

markri commented Jul 27, 2021

I use puppet to provision a temporary AWS EC2 instance (which will be destroyed after tests have finished). So in my case it is essential that it works on the first run. However I get this same error message

  • I'm sure it's a clean machine (using official CentOS 7 AMI image), so docker-ce hasn't been previously installed
  • If a run a subsequent run then it works fine. So it almost looks like the docker module isn't aware of the fresh installed docker-compose yet when bringing up a docker-compose stack in the same run
  • I tried suggestions above (creating a symlink at /usr/bin/docker-compose and also at /bin/docker-compose), but without satisifying result. Maybe it's not related to the PATH environment variable?

Maybe the provider could be instructed to use an absolute path instead of relying on the PATH environment variable, although at this point I'm not confident it might fix my issue. Would be happy to test though..

It's quite cumbersome to debug as I need to re-create an EC2 instance for each attempt to be able to reproduce the issue.

@mendhak
Copy link

mendhak commented Feb 11, 2022

@markri or anyone else, did you ever find a solution? I'm getting the same thing on Ubuntu 20.04, also on EC2. Same behaviors - clean install (destroy and recreate EC2), I have to run puppet apply twice, symlink doesn't work.

The only crude workaround I've found is to install Docker and Docker-Compose in the user-data init script. Before puppet ever runs. But this defeats the purpose of using this module.

echo "Install Docker"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
apt-get update
apt-get install -y docker-ce
usermod -aG docker ubuntu

echo "Install Docker Compose"
echo "TMPDIR=/var/tmp" >> /etc/environment
curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

@github-actions
Copy link

This issue has been marked as stale because it has been open for a while and has had no recent activity. If this issue is still important to you please drop a comment below and we will add this to our backlog to complete. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the stale label Apr 26, 2022
@mendhak
Copy link

mendhak commented Apr 26, 2022

If this issue is still important to you please drop a comment below and we will add this to our backlog to complete.

Yes please, again, this is important because we're currently having to run puppet apply twice.

@github-actions github-actions bot removed the stale label Apr 27, 2022
@canihavethisone
Copy link
Contributor

canihavethisone commented May 23, 2022

I use the sed script below to fix this issue, noting that it uses fixed Linux paths (not windows). I attempted to use an exec within the has_command thus, but it returns nil:
has_command(:dockercompose, `which docker-compose`) do

#!/bin/bash

# The following sed actions will patch an issue with the puppetlabs-docker module that requires 2 puppet runs

# Change path to your modules dir
target_path='/etc/puppetlabs/code/environments/production/modules'

## --- DO NOT EDIT BELOW THIS LINE --- ##

target_file_1='docker/lib/puppet/provider/docker_compose/ruby.rb'
target_file_2='docker/lib/puppet/provider/docker_network/ruby.rb'
target_file_3='docker/lib/puppet/provider/docker_stack/ruby.rb'
target_file_4='docker/lib/puppet/provider/docker_volume/ruby.rb'

find_1="has_command(:docker, command(:dockercmd)) do"
replace_1="has_command(:docker, '/usr/bin/docker') do"

find_2="has_command(:docker_compose, command(:dockercompose)) do"
replace_2="has_command(:dockercompose, '/usr/local/bin/docker-compose') do"


sed -i "s;$find_1;$replace_1;g" \
    $target_path/{$target_file_1,$target_file_2,$target_file_3,$target_file_4}

sed -i "s;$find_2;$replace_2;g" \
    $target_path/$target_file_1

I still find that a second puppet run is required when docker::selinux_enabled: true as it performs /etc/systemd/system/docker.service.d/service-overrides.conf]/seltype: seltype changed 'systemd_unit_file_t' to 'container_unit_file_t' and also on any docker service files in /etc/systemd/system/

@canihavethisone
Copy link
Contributor

canihavethisone commented May 23, 2022

@marrajo-afk I have created a pull request at #833. Can other users please test and verify these changes? Thanks.

@chelnak
Copy link
Contributor

chelnak commented May 31, 2022

Closed by #833

@chelnak chelnak closed this as completed May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants