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

(FM-7973) Adding hands on labs for bolt and puppet device #80

Merged
merged 29 commits into from Apr 26, 2019

Conversation

davinhanlon
Copy link
Contributor

No description provided.

@davinhanlon davinhanlon changed the title Addingpuppetdevicelab Adding puppet device lab Apr 16, 2019
@codecov
Copy link

codecov bot commented Apr 16, 2019

Codecov Report

Merging #80 into master will increase coverage by 0.1%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #80     +/-   ##
=========================================
+ Coverage   99.15%   99.26%   +0.1%     
=========================================
  Files          39       40      +1     
  Lines         948     1084    +136     
=========================================
+ Hits          940     1076    +136     
  Misses          8        8
Impacted Files Coverage Δ
lib/puppet/transport/panos.rb 100% <0%> (ø) ⬆️
lib/puppet/util/task_helper.rb 100% <0%> (ø) ⬆️
lib/puppet/util/network_device/panos/device.rb 100% <0%> (ø) ⬆️
lib/puppet_x/puppetlabs/panos/transport_shim.rb 100% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c278c3...63733de. Read the comment docs.

@DavidS DavidS changed the title Adding puppet device lab Adding hands on labs for bolt and puppet device Apr 23, 2019
@DavidS
Copy link
Contributor

DavidS commented Apr 23, 2019

This supersedes #79


Before doing any of this you're doing to need a few things to be set up: Ruby, bolt and a Palo Alto firewall that you can test against. Open a terminal window and follow the steps below.

1. Check if Ruby is installed by typing `ruby --version`. This will print out the version of Ruby that is installed. If it's not installed follow the instructions [here](https://rubyinstaller.org/downloads/) to install it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no reason to do this


3. Edit the file to tell bolt where to get the module, the module to retrieve and the version of the module. Those of your already familiar with Puppet will see that it uses the same format as existing Puppetfiles. For this purpose of this tutorial, enter the following details in the Puppetfile:
```
forge 'http://forge.puppetlabs.com'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This forge directive shouldn't be necessary and may confuse users who already have a Puppetfile


OK, so now we're going to use bolt to download the [Puppet Palo Alto module](https://forge.puppet.com/puppetlabs/panos) from [the Forge](https://forge.puppet.com/) to your local workstation. This can be done by creating a [Puppetfile](https://puppet.com/docs/bolt/latest/installing_tasks_from_the_forge.html#task-8928) and adding a link to the Forge module.

1. Go to your bolt working directory. This is `$HOME/.puppetlabs/bolt`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better for users to just start with a project directory in an arbitrary spot. That seems to be more common than using this path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adreyer this has been updated to point them in using https://puppet.com/docs/bolt/latest/bolt_project_directories.html#local-project-directory rather than the .puppetlabs/bolt directory - if you could have a look over the change to see if it makes sense.


2. Create a file called `inventory.yaml`.

3. Edit the file to provide details about the Palo Alto firewall you want to manage. The following details will needed: hostname or IP of the Palo Alto firewall, user name, password or api key. For this tutorial I'm using a username and password combination. I've also chosen to set SSL to false. By default this is set to true meaning that the SSL certificate needs to be verified before you can connect to the firewall - I've set this to false for this demo.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have examples of how to setup the ssl certificate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup of SSL certificates would be on the firewall itself, and I believe is covered in the docs (https://docs.paloaltonetworks.com/pan-os/8-0/pan-os-admin/certificate-management.html)

For using self signed certs we have a document on confluence (https://confluence.puppetlabs.com/display/ECO/Using+self+signed+certs+on+Palo+Alto+VMPooler+Images) for our own testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the first step we're talking about setting up a VM for testing. I would not be surprised if a significant portion of users will try running this against their actual devices (hopefully in a test lab).

To make sure that this reflects a production setup and to show that it doesn't break the bank to enable SSL verification, this section needs to describe how to retrieve the fingerprint from the browser or target system and how to set it up here.


Type `bolt task run panos::apikey -n pan --debug` where -n represents the nodes, with `pan` the alias we set in the `inventory.yaml` file and `--debug` represents that we want to get debug level output. If everything is working as planned you should be able to see that the task runs successfully and returns an apikey as expected. Examining the debug output you will notice a few interesting things:

1. The task target is localhost, meaning it ran on your localhost machine. It is possible for bolt to execute on [remote targets](https://puppet.com/docs/bolt/latest/bolt_configuration_options.html#remote-transport-configuration-options) for infrastructure that is located on a different network segment to your localhost.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. The target is pan which is a remote target. By default tasks for remote targets run on localhost. By setting run-as proxy to something else the task can run elsewhere. I think it's probably better to avoid that level of detail at this point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

@@ -0,0 +1,38 @@
# Execute a Manifest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be "applying a manifest"

@DavidS DavidS changed the title Adding hands on labs for bolt and puppet device (FM-7973) Adding hands on labs for bolt and puppet device Apr 23, 2019
@Thomas-Franklin Thomas-Franklin added the feature New feature or request label Apr 25, 2019
@Thomas-Franklin
Copy link
Contributor

Tagging @clairecadman - if you get a moment could you check over these docs? :-)

@clairecadman
Copy link
Contributor

@Thomas-Franklin Sure! I'll take a look at this either later today or tomorrow morning. :)

@DavidS
Copy link
Contributor

DavidS commented Apr 25, 2019

Can we get a link to the docs/ folder into the main README, so that the forge page will eventually link back to the tutorials? I fear otherwise the excellent content here will not be easily found.

@@ -0,0 +1,16 @@
# Install Prerequisites

Before you begin, you need a Ruby, Bolt and a Palo Alto firewall that you can test against. Open a terminal window and follow the steps below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidS You give instructions on downloading Bolt and Palo Alto, but not Ruby. Is this something they will already have? If so, do you need mention it here when you don't talk about it again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installing the bolt package, like the AIO and the PDK packages, already gives you a ruby install.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... so this sentence needs to be fixed to not say ruby.

@@ -27,12 +21,22 @@ nodes:
ssl_fingerprint: <certificate SHA256 fingerprint>
```

*Note*: The `name` will need to match the `Common Name (CN)` of the certificate of the firewall, for Puppet employees using VMPooler images the CN name may be a generated string that does not match the FQDN, it is advisable to edit the hosts file in this instance, or if this does not suit simply replace `ssl_fingerprint: <certificate SHA256 fingerprint>` with `ssl: false` which will mean that no SSL validation is performed.
The `name` needs to match the `Common Name (CN)` of the certificate of the firewall. In this example, we have combined username and password.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clairecadman I am not sure of this sentence as it seems to combine different things.

The sentence about name matching the CN is fine, but for the second part, maybe In this example, we are using the username and password for authenticating with the device. since the module accepts a user/password combination or an apikey

Copy link
Contributor

@clairecadman clairecadman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavidS I've finished editing, please review before merging. I think you should be consistent with the name of the module, either call it the "panos module" or "palo alto module". These are used interchangeably, which makes it seem like there is two different modules. Thanks!


Now that you have set up your node as a proxy to the device, you can run the `puppet device` commands. If you are using Puppet Enterprise (PE), these commands are executed from here to being your device nodes under management.

1. From the command line of the node on which your device is configured, run `puppet device --resource address --target firewall.example.com` to return the addresses configured in the PANOS firewall. The output is Puppet code, similar to:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be --resource panos_address vs --resource address

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@DavidS DavidS merged commit 626b7df into master Apr 26, 2019
@DavidS DavidS deleted the addingpuppetdevicelab branch April 26, 2019 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants