Tested with:
- Python 3.9
- Python-ovh 1.0
- Ansible 2.12+
- flake8
This module can be installed as a collection
ansible-galaxy collection install git+https://github.com/synthesio/infra-ovh-ansible-module
This collection provides the following modules:
dedicated_nasha_manage_partition
dedicated_server_boot
dedicated_server_boot_wait
dedicated_server_display_name
dedicated_server_info
dedicated_server_install
dedicated_server_install_wait
dedicated_server_monitoring
dedicated_server_networkinterfacecontroller
dedicated_server_rescuesshkey
dedicated_server_terminate
dedicated_server_vrack
domain
installation_template
ip_info
ip_move
ip_reverse
me_sshkey
public_cloud_block_storage
public_cloud_block_storage_instance
public_cloud_flavorid_info
public_cloud_imageid_info
public_cloud_instance
public_cloud_instance_delete
public_cloud_instance_flavor_change
public_cloud_instance_id
public_cloud_instance_info
public_cloud_instance_interface
public_cloud_instance_shelving
public_cloud_monthly_billing
public_cloud_object_storage
public_cloud_object_storage_policy
public_cloud_private_network_info
vps_display_name
vps_info
You can read the documentation of every modules with ansible-doc synthesio.ovh.$modules
An example for a custom template to install a dedicated server is present in roles/ovhtemplate
folder
The collection path must be defined in your ansible.cfg
:
[defaults]
collections_paths = collections/
In /etc/ovh.conf
:
[default]
; general configuration: default endpoint
endpoint=ovh-eu
[ovh-eu]
; configuration specific to 'ovh-eu' endpoint
application_key=<YOUR APPLICATION KEY>
application_secret=<YOUR APPLICATIOM SECRET>
consumer_key=<YOUR CONSUMER KEY>
Alternatively, you can provide credentials as module attributes:
- name: Add server to vrack
synthesio.ovh.dedicated_server_vrack:
endpoint: "ovh-eu"
application_key: "<YOUR APPLICATION KEY>"
application_secret: "<YOUR APPLICATIOM SECRET>"
consumer_key: "<YOUR CONSUMER KEY>"
vrack: "{{ vrackid }}"
service_name: "{{ ovhname }}"
This allows you to store them in Ansible vault or to use any lookup plugin to retrieve them.
Here are a few examples of what you can do. Please read the module for everything else, it most probably does it!
As this is a collection now you must declare it in each task.
A few examples:
- name: Add server to vrack
synthesio.ovh.dedicated_server_vrack:
service_name: "{{ ovhname }}"
vrack: "{{ vrackid }}"
- name: Move IP to a given host
synthesio.ovh.ip_move:
service_name: "{{ ovhname }}"
ip: "{{ ip }}"
- name: Add server IP to DNS
synthesio.ovh.domain:
domain: "example.com"
value: "192.0.2.1"
record_type: "A"
name: "internal.bar"
record_ttl: 10
append: true
- name: Install new dedicated server
synthesio.ovh.dedicated_server_install:
service_name: "ns12345.ip-1-2-3.eu"
hostname: "server01.example.net"
template: "debian10_64"
- name: Wait for the server installation
synthesio.ovh.dedicated_server_install_wait:
service_name: "ns12345.ip-1-2-3.eu"
max_retry: "240"
sleep: "10"
- name: Install new dedicated server
synthesio.ovh.dedicated_server_install:
service_name: "ns12345.ip-1-2-3.eu"
hostname: "server01.example.net"
template: "debian10_64"
soft_raid_devices: "2"
- name: run a public cloud installation
synthesio.ovh.public_cloud_instance:
name: "{{ inventory_hostname }}"
ssh_key_id: "{{ ssh_key_id }}"
service_name: "{{ service_name }}"
networks: "{{ networks }}"
flavor_id: "{{ flavor_id }}"
region: "{{ region }}"
image_id: "{{ image_id }}"