Skip to content

Commit

Permalink
Updating to allow for multiple config blocks (#4)
Browse files Browse the repository at this point in the history
* Adjusted meta file and emptied defaults file

* Added including a commented name in the ddclient.conf file

this is to allow multiple config options in one file.

* changed from `-U` to `--upgrade`

* Testing adjustment

* Trying fixes

* More Testing

* More crazy testing

* More Testing

* Totally Changed template

* Wild Test

* Testing

* Trying Changes
  • Loading branch information
jpartain89 authored Apr 5, 2018
1 parent 618cf02 commit 0def709
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ before_install:
- sudo -H pip install -U ansible-vault

install:
- sudo -H pip install -U ansible
- sudo -H pip install --upgrade ansible
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"

script:
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ CPANM will be installed, along with Perl and `libio-socket-ssl-perl`

## Role Variables

Each line under `ddclient_conf` will be placed in `/etc/ddclient/ddclient.conf` as-is.
Each line under `ddclient_conf` will be placed in `/etc/ddclient/ddclient.conf` as-is, except for `name`. I added this distinction in case you had multiple addresses you configured using DDClient.

```bash
ddclient_conf:
- "protocol=dyndns2"
- "use=web"
- "server=domains.google.com"
name: DynDNS2
- "protocol=dyndns2"
- "use=web"
- "server=domains.google.com"
name: Other
- "protocol=other"
...
```

## Example Playbook
Expand All @@ -28,9 +32,10 @@ ddclient_conf:

vars:
ddclient_conf:
- "protocol=dyndns2"
- "use=web"
- "server=domains.google.com"
name: DynDNS2
- "protocol=dyndns2"
- "use=web"
- "server=domains.google.com"

roles:
- jpartain89.ddclient
Expand Down
9 changes: 0 additions & 9 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
---
# ddclient/defaults/main.yml

#ddclient_conf:
# - "protocol="
# - "use=
# - "server="
# - "ssl="
# - "login="
# - "password="
# - "address
3 changes: 2 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ galaxy_info:
- name: Ubuntu
versions:
- xenial
- wily
- zesty
- name: Debian
versions:
- wheezy
- stretch
- jessie
galaxy_tags:
- development
- system
Expand Down
7 changes: 3 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
dest: "{{ ddclient_git_repo_dest }}"
update: yes
accept_hostkey: yes
register: ddclient_git_cloned
register: _ddclient_git_cloned

- name: Install apt Dependencies
apt:
Expand All @@ -28,7 +28,7 @@
checksum: yes
times: no
delegate_to: "{{ inventory_hostname }}"
when: ddclient_git_cloned.changed
when: _ddclient_git_cloned.changed
become: true

- name: Create /etc and /var/cache Directories
Expand Down Expand Up @@ -59,7 +59,7 @@
times: no
when:
- ansible_os_family == "Debian"
- ddclient_git_cloned.changed
- _ddclient_git_cloned.changed
delegate_to: "{{ inventory_hostname }}"
become: true
notify: Autostart DDClient
Expand Down Expand Up @@ -88,4 +88,3 @@
- "JSON::PP"
become: true
notify: Start DDClient

28 changes: 26 additions & 2 deletions templates/ddclient.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# {{ ansible_managed }}
pid={{ ddclient_pid_file }}
{% for lines in ddclient_conf %}
{{ lines }}
{% for name in ddclient_conf %}
# {{ name }}
{% if name.protocol is defined %}
protocol={{ name.protocol }}
{% endif -%}
{% if name.use is defined %}
use={{ name.use }}
{% endif -%}
{% if name.server is defined %}
server={{ name.server }}
{% endif -%}
{% if name.ssl is defined %}
ssl={{ name.ssl }}
{% endif -%}
{% if name.zone is defined %}
zone={{ name.zone }}
{% endif %}
{% if name.login is defined %}
login={{ name.login }}
{% endif -%}
{% if name.password is defined %}
password={{ name.password }}
{% endif -%}
{% if name.address is defined %}
{{ name.address }}
{% endif -%}
{% endfor %}
11 changes: 10 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
# ddclient/vars/main.yml

ddclient_git_repo_http: "https://github.com/wimpunk/ddclient.git"
ddclient_git_repo_dest: "/usr/local/lib/ddclient-git"
ddclient_git_repo_dest: "{{ ansible_user_dir }}/git/ddclient"
ddclient_pid_file: /var/run/ddclient.pid
ddclient_conf:
- name: "Blank"
protocol: value
use: value
server: value
ssl: value
login: value
password: value
address: value

0 comments on commit 0def709

Please sign in to comment.