This repo has been forked from https://github.com/phoenixnap/ansible-collection-pnap and the docs have been updated to address how to recovery instantly using Veeam on PhoenixNAP BMC
Ansible collection of modules for interacting with the Bare Metal Cloud API. This collection contains the server module which allows you to automate Bare Metal Cloud server provisioning and management.
Bare Metal Cloud • Ansible Galaxy • Developers Portal • Knowledge Base • Support
- Bare Metal Cloud account
- Ansible 2.9+
- Python 2 (version 2.7) or Python 3 (versions 3.5 and higher)
- Python requests package
- Go to the Bare Metal Cloud signup page.
- Follow the prompts to set up your account.
- Use your credentials to log in to Bare Metal Cloud portal.
Follow these helpful tutorials to learn how to install Ansible on Ubuntu and Windows machines.
- How to Install and Configure Ansible on Ubuntu 20.04
- How to Install and Configure Ansible on Windows
- How to Install and Configure Ansible on Mac OSX
This Ansible collection contains the server module which requires the Python requests HTTP library to work properly. If you don't have it installed on your machine already, run this command to install it:
pip install requests
Now install the Ansible collection by running:
ansible-galaxy collection install phoenixnap.bmc
You can view the server module documentation with this command:
ansible-doc phoenixnap.bmc.server
You need to create a configuration file called config.yaml
and save it in the user home directory. This file is used to authenticate access to your Bare Metal Cloud resources.
In your home directory, create a folder .pnap
and a config.yaml
file inside it.
This file needs to contain only two lines of code:
clientId: <enter your client id>
clientSecret: <enter your client secret>
To get the values for the clientId and clientSecret, follow these steps:
- Log in to the Bare Metal Cloud portal.
- On the left side menu, click on API Credentials.
- Click the Create Credentials button.
- Fill in the Name and Description fields, select the permissions scope and click Create.
- In the table, click on Actions and select View Credentials from the dropdown.
- Copy the values from the Client ID and Client Secret fields into your
config.yaml
file.
Ansible Playbooks allow you to interact with your Bare Metal Cloud resources. You can create and delete servers as well as perform power actions with simple code instructions.
This example shows you how to deploy a Windows and ESXi Server in PhoenixNAP. On the Windows server, you can install Veeam VBR and then configure the ESXi Server as a host server in Veeam
Ansible playbooks are YAML files and follow the format playbook_name.yml
. The name part of the filename should contain the action you want to perform. In our case, since we are creating a couple of servers, the filename is playbook_create.yaml
.
Once you've created the file, open it and paste this code (this file is also checked into this repo):
Note: Be default, the servers you provision will be locked down. Please update the management_access_allowed_ips and rdp_allowed_ips config values below to reflect your public IP.
- name: Create servers for Instant Recovery
hosts: localhost
gather_facts: false
vars_files:
- ~/.pnap/config.yaml
collections:
- phoenixnap.bmc
tasks:
- server:
client_id: "{{clientId}}"
client_secret: "{{clientSecret}}"
hostnames: veeam-ir-esxi
location: PHX
os: esxi/esxi70u2
type: d1.c2.medium
state: present
ssh_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
management_access_allowed_ips: ["192.168.1.100"]
- server:
client_id: "{{clientId}}"
client_secret: "{{clientSecret}}"
hostnames: veeam-ir-windows
location: PHX
os: windows/srv2019dc
type: s1.c2.medium
state: present
rdp_allowed_ips: [192.168.1.100]
ssh_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
To run the playbook use the following command
ansible-playbook playbook_create.yaml -v
The -v
option is important as this option will print out the credentials that you need to log into the resources
For more examples, check out this helpful tutorial: Bare Metal Cloud Playbook Examples