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

Redeploy stack exec #322

Closed
longnameislong opened this issue Aug 31, 2018 · 5 comments · Fixed by #433
Closed

Redeploy stack exec #322

longnameislong opened this issue Aug 31, 2018 · 5 comments · Fixed by #433

Comments

@longnameislong
Copy link

What you expected to happen?

I require that my stacks are redeployed each run when a change is detected. I am using a file resource to deploy my stack file and when that deploys a change I and using a subscribe on my stack class to run the new exec I have added below.

How to reproduce it?

Deploy a stack and then change the stack file, run puppet with changes and the changes will not be added as the unless option exists

Anything else we need to know?

FYI - I am very new to GIT and puppet that is why I am raising this as an issue instead of a pull, apologies

Could I please ask for this to be added to the module as I am currently running a fork of the project that includes this change.

Code: -extract of stacks.pp

if $ensure == 'present'{
      $docker_stack_flags = docker_stack_flags ({
      stack_name => $stack_name,
      bundle_file => $bundle_file,
      compose_file => $compose_file,
      prune => $prune,
      with_registry_auth => $with_registry_auth,
      resolve_image => $resolve_image,
      })

      $exec_stack = "${docker_command} deploy ${docker_stack_flags} ${stack_name}"
      $unless_stack = "${docker_command} ls | grep ${stack_name}"

      # If you need to redeploy a stack, you can notify Docker::Stack[$stack_name]
      exec { "docker stack refresh ${stack_name}":
        refreshonly => true,
        command     => $exec_stack,
        path        => ['/bin', '/usr/bin'],
        before      => Exec["docker stack create ${stack_name}"],
      }

      exec { "docker stack create ${stack_name}":
        command => $exec_stack,
        unless  => $unless_stack,
        path    => ['/bin', '/usr/bin'],
    }
  }
@longnameislong longnameislong changed the title Redeploy stack exec with onlyif Redeploy stack exec Aug 31, 2018
@davejrt
Copy link
Contributor

davejrt commented Sep 4, 2018

I've created a ticket and added this to our internal backlog

@PierreR
Copy link
Contributor

PierreR commented Jan 28, 2019

I have the same problem. When my docker-compose file changes, there is a notify to trigger a redeploy but nothing happens even if the logs seems to say otherwise with :

Info: Computing checksum on file /etc/swarm/docker-compose-monitoring.yml
Info: /Stage[main]/Application::Docker::Swarm_manager/Application::Docker::Stack[monitoring]/File[/etc/swarm/docker-compose-monitoring.yml]: Filebucketed /etc/swarm/docker-compose-monitoring.yml to puppet with sum 42b3ef3f34ee00271bad335e561a8f88
Notice: /Stage[main]/Application::Docker::Swarm_manager/Application::Docker::Stack[monitoring]/File[/etc/swarm/docker-compose-monitoring.yml]/content: content changed '{md5}42b3ef3f34ee00271bad335e561a8f88' to '{md5}9fdfab8603f25eb29dd7ad1f7795750c'
Info: /Stage[main]/Application::Docker::Swarm_manager/Application::Docker::Stack[monitoring]/File[/etc/swarm/docker-compose-monitoring.yml]: Scheduling refresh of Docker::Stack[monitoring]
Info: Docker::Stack[monitoring]: Scheduling refresh of Exec[docker stack create monitoring]

This was quite unexpected knowing that running docker stack deploy -c /etc/swarm/docker-compose-monitoring monitoring would update the stack without any issue.

@mattstrain
Copy link

So we were having the same issue as this but if I update to the new version and use this new type I get a notice message on every puppet run?
Notice: /Stage[main]/xxx_docker::Service::Stack[v52]/Docker_stack[v52]/ensure: created

@davejrt
Copy link
Contributor

davejrt commented Mar 8, 2019

@mattstrain can you please provide a manifest and a more complete log file?

@kwek
Copy link

kwek commented Sep 11, 2020

Are you sure this is fixed? Triggering a refresh on docker::stack does not refresh it. The same applies for docker_stack.

I applied the changes in #657 . But not sure how this fix this for docker_stack. Any hints?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants