Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

Latest commit

 

History

History

06-downloading-and-running-existing-tasks

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Running Existing Tasks

Difficulty: Intermediate

Time: Approximately 10 minutes

In this exercise you will explore existing tasks, including several tasks that take advantage of Puppet under-the-hood.

Prerequisites

Complete the following before you start this lesson:

  1. Installing Bolt
  2. Setting up test nodes
  3. Running Commands
  4. Running Scripts

Inspect installed tasks

Bolt is packaged with useful modules and task content.

  • Run the 'bolt task show' command to view a list of the tasks installed in the previous exercise.

    bolt task show
    

    The result:

    facts                              Gather system facts
    facts::bash                        Gather system facts using bash
    facts::powershell                  Gather system facts using powershell
    facts::ruby                        Gather system facts using ruby and facter
    package                            Manage and inspect the state of packages
    puppet_agent::install              Install the Puppet agent package
    puppet_agent::install_powershell
    puppet_agent::install_shell
    puppet_agent::version              Get the version of the Puppet agent package installed. Returns nothing if none present.
    puppet_agent::version_powershell
    puppet_agent::version_shell
    puppet_conf                        Inspect puppet agent configuration settings
    service                            Manage and inspect the state of services
    service::linux                     Manage the state of services (without a puppet agent)
    service::windows                   Manage the state of Windows services (without a puppet agent)
    
    Use bolt task show <task-name> to view details and parameters for a specific task.
    

Use the puppet_agent module to install puppet agent.

Install puppet agent with the install_agent task

bolt task run puppet_agent::install -n all --run-as root

The result:

  Installed:
  puppet-agent.x86_64 0:6.0.1-1.el7                                             
  
  Complete!
  Loaded plugins: fastestmirror
  Loading mirror speeds from cached hostfile
   * base: mirror.tocici.com
   * extras: mirror.tocici.com
   * updates: ftp.osuosl.org
  No packages marked for update
  {
  }
 Successful on 3 nodes: node1,node2,node3
 Ran on 3 nodes in 68.71 seconds

View and use parameters for a specific task

  1. Run bolt task show package to view the parameters that the package task uses.

    bolt task show package
    

    The result:

    package - Manage and inspect the state of packages
    
    USAGE:
    bolt task run --nodes <node-name> package action=<value> name=<value> version=<value> provider=<value>
    
    PARAMETERS:
    - action: Enum[install, status, uninstall, upgrade]
        The operation (install, status, uninstall and upgrade) to perform on the package
    - name: String[1]
        The name of the package to be manipulated
    - version: Optional[String[1]]
        Version numbers must match the full version to install, including release if the provider uses a release moniker. Ranges or semver patterns are not accepted except for the gem package provider. For example, to install the bash package from the rpm bash-4.1.2-29.el6.x86_64.rpm, use the string '4.1.2-29.el6'.
    - provider: Optional[String[1]]
        The provider to use to manage or inspect the package, defaults to the system package manager
    
    MODULE:
    built-in module
    
  2. Using parameters for the package task, check on the status of the bash package:

    bolt task run package action=status name=bash --nodes node1
    

    The result:

    Started on node1...
    Finished on node1:
      {
        "status": "up to date",
        "version": "4.2.46-30.el7"
      }
    Successful on 1 node: node1
    Ran on 1 node in 3.84 seconds
    
  3. Using parameters for the package task, install the vim package across all your nodes:

    bolt task run package action=install name=vim --nodes all --run-as root
    

    The result:

    Started on node1...
    Started on node3...
    Started on node2...
    Finished on node1:
      {
        "status": "present",
        "version": "2:7.4.160-4.el7"
      }
    Finished on node3:
      {
        "status": "installed",
        "version": "2:7.4.160-4.el7"
      }
    Finished on node2:
      {
        "status": "installed",
        "version": "2:7.4.160-4.el7"
      }
    Successful on 3 nodes: node1,node2,node3
    Ran on 3 nodes in 10.03 seconds
    

More tips, tricks and ideas on the Tasks Playground

See the installing modules documentation to learn how to install external modules. These exercises introduce you to Puppet tasks. You'll find lots more tips, tricks, examples and hacks on the Puppet Tasks Playground.

Next steps

Now that you know how to run existing tasks with Bolt you can move on to:

Writing Plans