Dynamic DNS using YDNS for a Oracle Cloud instance
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.0 KiB

Ansible — Dynamic DNS using YDNS

This playbook creates a bash script from the following fork. The script sends the public IP of an instance on Oracle Cloud to YDNS. A Cron job runs the script once every hour.

Assumption: Instance deployed using either one of the Terraform scripts below,

Code Mirrors


Install the following before running the playbook,

pip install oci
ansible-galaxy collection install oracle.oci

Dynamic Inventory

The Oracle Ansible Inventory Plugin populates public Ubuntu instances.

All target Ubuntu instances must have the freeform tag ydns_host: <hostname>.


  1. Update inventory/oracle.oci.yml,
    1. Specify the region where you have deployed your server on Oracle Cloud. List of regions are at docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm.
    2. Configure the authentication as per the Oracle Guide
  2. Set username and ssh authentication in inventory/group_vars/
  3. Set username and password for YDNS in inventory/group_vars/ydns.yml. Use inventory/group_vars/ydns.yml.sample as a reference.

To use more than a single SSH keypair (with passphrases), use ssh-agent to store them.

Run the following command to start ssh-agent,

$ eval "$(ssh-agent -s)"

Add each keypair using the following command,

$ ssh-add <path to keypair>


Run the playbook using the following command,



Encrypt sensitive files (SSH private keys) before saving them. .gitignore must contain the unencrypted file paths.

Use the following command to decrypt the files after cloning the repository,

$ ./bin/decrypt.sh

Use the following command after running terraform to update the encrypted files,

$ ./bin/encrypt.sh <gpg key id>