Jira (PUP-10135) Have a command to stop and start all puppet services

6 views
Skip to first unread message

Jason Stewart (JIRA)

unread,
Nov 12, 2019, 6:19:04 AM11/12/19
to puppe...@googlegroups.com
Jason Stewart created an issue
 
Puppet / Improvement PUP-10135
Have a command to stop and start all puppet services
Issue Type: Improvement Improvement
Assignee: Unassigned
Attachments: stopstartexample.rtf
Created: 2019/11/12 3:18 AM
Priority: Normal Normal
Reporter: Jason Stewart

Hi Guys,

 

Would it be possible to have a command baked into PE  that can be run to stop, start and restart all puppet services in the correct order ie puppet infra run stopservices , startservices, restartservices? This would mean we would not need to ask customers to run several commands to stop and start all services related to puppet.

I put something together with a rough idea of how I could achieve this but it would need a touch from the pros!

I was thinking something like the following would work, but it may need some more logic to handle mcollective and pe-activemq...

```

#!/bin/bash

declare -a arrPuppetServiceStop=("puppet" "pe-puppetserver" "pe-activemq" "mcollective" "pe-puppetdb" "pe-console-services" "pe-nginx" "pe-orchestration-services")

declare -a arrPuppetServiceStart=("pe-postgresql" "pe-puppetserver" "pe-activemq" "mcollective" "pe-puppetdb" "pe-console-services" "pe-nginx" "pe-orchestration-services" "puppet")

 

function puppetstop(){

    servicesarr=("$@")

    for service in ${servicesarr[@]}

        do

           echo "Attempting to stop $service"

           puppet resource service $service ensure=stopped

         done

}

 

 

function puppetstart(){

    servicesarr=("$@")

    for service in ${servicesarr[@]}

        do

           echo "Attempting to start $service"

           puppet resource service $service ensure=running

         done

}

 

function puppetstatuscheck(){

    servicesarr=("$@")

    status=("$1")

    for service in ${servicesarr[@]}

        do

           echo "Checking status of $service"

           puppet resource service pe-puppetserver | grep ensure | sed -e 's|[",'\'']||g' | awk '{split($0,s," "); print s[3];}'

         done

}

 

state="$1"

case "$state" in

   stop)

      echo "Trigger Stop action"

      puppetstop "${arrPuppetServiceStop[@]}"

      ;;

   start)

       echo "Trigger Start Action"

       puppetstart "${arrPuppetServiceStart[@]}"

       ;;

 

    *)

     echo "Only accepts Stop and Start"

     exit 1

esac

```

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Nov 12, 2019, 2:51:04 PM11/12/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Hi Guys,

 

Would it be possible to have a command baked into PE  that can be run to stop, start and restart all puppet services in the correct order ie puppet infra run stopservices , startservices, restartservices? This would mean we would not need to ask customers to run several commands to stop and start all services related to puppet.

I put something together with a rough idea of how I could achieve this but it would need a touch from the pros!

I was thinking something like the following would work, but it may need some more logic to handle mcollective and pe-activemq...

``` {code:bash}
echo $state

case "$state" in

  
stop)

     
echo "Trigger Stop action"

     
puppetstop "${arrPuppetServiceStop[@]}"

     
;;

  
start)

      
echo "Trigger Start Action"

      
puppetstart "${arrPuppetServiceStart[@]}"

      
;;
    check)
         echo "checking"
       puppetstatuscheck "${arrPuppetServiceStop[@]}"
           ;;
*)

    
echo "Only accepts Stop and Start"

    
exit 1

esac
{code}
```

 

Josh Cooper (JIRA)

unread,
Nov 12, 2019, 2:52:03 PM11/12/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Nov 12, 2019, 2:52:04 PM11/12/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: InfraCore Installer and Management

Joshua Partlow (JIRA)

unread,
Nov 12, 2019, 3:14:04 PM11/12/19
to puppe...@googlegroups.com
Joshua Partlow commented on Improvement PUP-10135
 
Re: Have a command to stop and start all puppet services

Ah, sorry, didn't see this. We could add an action to puppet-infra, and/or possibly a bolt plan. I'll switch this to the PE project and it'll flow into our backlog, though I'm not certain what priority it will end up with.

The installer uses [pe_install::upgrade::stop_services|https://github.com/puppetlabs/puppet-enterprise-modules/blob/master/modules/pe_install/manifests/upgrade/stop_services.pp].

Reply all
Reply to author
Forward
0 new messages