Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
bdeed4cd46 | |||
5e1ebc6329 | |||
767316125d | |||
995592a555 |
32
README.md
32
README.md
@ -12,6 +12,21 @@ Ansible libraries for managing Gandi resources.
|
|||||||
gather_facts: false
|
gather_facts: false
|
||||||
connection: local
|
connection: local
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Prepare Python dependencies
|
||||||
|
become: true
|
||||||
|
apt:
|
||||||
|
name: python3-pip
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install dns-lexicon system wide
|
||||||
|
become: true
|
||||||
|
pip:
|
||||||
|
name: "{{ item }}"
|
||||||
|
executable: /usr/bin/pip3
|
||||||
|
with_items:
|
||||||
|
- dns-lexicon==3.3.19
|
||||||
|
- cryptography==2.8
|
||||||
|
|
||||||
- name: Create foobar.autonomic.zone
|
- name: Create foobar.autonomic.zone
|
||||||
gandi_dns:
|
gandi_dns:
|
||||||
gandi_rest_token: abc...
|
gandi_rest_token: abc...
|
||||||
@ -32,17 +47,11 @@ Ansible libraries for managing Gandi resources.
|
|||||||
- [dns-lexicon >= 3.3.19](https://pypi.org/project/dns-lexicon/) (if using `gandi_dns` module)
|
- [dns-lexicon >= 3.3.19](https://pypi.org/project/dns-lexicon/) (if using `gandi_dns` module)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ pip install ansible==2.6.9 "dns-lexicon[gandi]==3.3.19"
|
$ pip install ansible==2.6.9 dns-lexicon==3.3.19
|
||||||
```
|
```
|
||||||
|
|
||||||
These should be present on the localhost where you run Ansible.
|
These should be present on the localhost where you run Ansible.
|
||||||
|
|
||||||
You can also get `dns-lexicon` via `apt`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ apt install -y python3-lexicon
|
|
||||||
```
|
|
||||||
|
|
||||||
## Gandi DNS Setup
|
## Gandi DNS Setup
|
||||||
|
|
||||||
If you want to use the `gandi_dns` module you need to prepare the environment.
|
If you want to use the `gandi_dns` module you need to prepare the environment.
|
||||||
@ -69,10 +78,17 @@ task or expose it in the environment and it will be picked up.
|
|||||||
Include an entry in your `requirements.yml` like so.
|
Include an entry in your `requirements.yml` like so.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- src: https://git.autonomic.zone/autonomic-cooperative/autonomic.gandi/archive/0.0.4.tar.gz
|
- src: https://git.autonomic.zone/autonomic-cooperative/autonomic.gandi/archive/0.0.5.tar.gz
|
||||||
name: autonomic.gandi
|
name: autonomic.gandi
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [releases](https://git.autonomic.zone/autonomic-cooperative/autonomic.gandi/releases) for which is the latest version.
|
See the [releases](https://git.autonomic.zone/autonomic-cooperative/autonomic.gandi/releases) for which is the latest version.
|
||||||
|
|
||||||
Then make sure to download the role with `ansible-galaxy install -r requirements.yml`.
|
Then make sure to download the role with `ansible-galaxy install -r requirements.yml`.
|
||||||
|
|
||||||
|
Note, we also keep a mirror on [git.coop](https://git.coop) for when we run internal Gitea upgrades.
|
||||||
|
|
||||||
|
```
|
||||||
|
- src: https://git.coop/decentral1se/autonomic.gandi/-/archive/0.0.5/autonomic.gandi-0.0.5.tar.gz
|
||||||
|
name: autonomic.gandi
|
||||||
|
```
|
||||||
|
@ -70,18 +70,19 @@ def error_msg(domain):
|
|||||||
).format(domain=domain)
|
).format(domain=domain)
|
||||||
|
|
||||||
|
|
||||||
def get_env():
|
def get_env(module):
|
||||||
"""Build environment for running command-line commands."""
|
"""Build environment for running command-line commands."""
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["PROVIDER"] = "gandi"
|
env["PROVIDER"] = "gandi"
|
||||||
env["LEXICON_GANDI_API_PROTOCOL"] = "rest"
|
env["LEXICON_GANDI_API_PROTOCOL"] = "rest"
|
||||||
|
env["LEXICON_GANDI_AUTH_TOKEN"] = module.params["gandi_rest_token"]
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
def retrieve_domain_info(module):
|
def retrieve_domain_info(module):
|
||||||
"""Retrieve all information about a specific domain."""
|
"""Retrieve all information about a specific domain."""
|
||||||
domain = module.params["domain"]
|
domain = module.params["domain"]
|
||||||
env = get_env()
|
env = get_env(module)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return json.loads(
|
return json.loads(
|
||||||
@ -98,7 +99,7 @@ def create_domain(module):
|
|||||||
"""Create a new DNS entry."""
|
"""Create a new DNS entry."""
|
||||||
domain = module.params["domain"]
|
domain = module.params["domain"]
|
||||||
ipv4 = module.params["ipv4"]
|
ipv4 = module.params["ipv4"]
|
||||||
env = get_env()
|
env = get_env(module)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return json.loads(
|
return json.loads(
|
||||||
@ -127,7 +128,7 @@ def delete_domain(module):
|
|||||||
"""Delete an existing DNS entry."""
|
"""Delete an existing DNS entry."""
|
||||||
domain = module.params["domain"]
|
domain = module.params["domain"]
|
||||||
ipv4 = module.params["ipv4"]
|
ipv4 = module.params["ipv4"]
|
||||||
env = get_env()
|
env = get_env(module)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return json.loads(
|
return json.loads(
|
||||||
|
Reference in New Issue
Block a user