Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Playbook for Uberspace 7 #1

Open
dennzimm opened this issue Mar 31, 2018 · 1 comment
Open

Update Playbook for Uberspace 7 #1

dennzimm opened this issue Mar 31, 2018 · 1 comment

Comments

@dennzimm
Copy link

No description provided.

@The-Compiler
Copy link

The-Compiler commented Oct 23, 2019

FWIW I wrote something for domains. Disclaimer: It's quite a hack, tailored to my setup and relies on uberspace internals.

---

- name: Fetch uberspace domains
  fetch:
    src: /opt/uberspace/userfacts/{{ ansible_user }}/domains.yml
    dest: tmp/{{ inventory_hostname }}/
    flat: true
    fail_on_missing: false
  register: fetch_result

- name: Read uberspace domains
  include_vars:
    file: tmp/{{ inventory_hostname }}/domains.yml
    name: remote_domains
  when: fetch_result.changed

- name: Set uberspace domain defaults
  set_fact:
    remote_domains: []
  when: not fetch_result.changed

#---------

- name: Add new domains
  loop: "{{ uberspace_domains|product(['web', 'mail'])|list }}"
  when: item[0] not in remote_domains
  command: uberspace {{ item[1] }} domain add {{ item[0] }}
  register: add_output

- name: Print output
  loop: "{{ add_output.results|list }}"
  when: item.changed
  debug:
    msg: "{{ item['stdout_lines'] }}"

- name: Add www domains
  loop: "{{ uberspace_domains }}"
  when: '"www." + item not in remote_domains and item|select("equalto", ".")|list|length == 1'
  command: uberspace web domain add www.{{ item }}

- name: Remove old domains
  loop: "{{ remote_domains|product(['web', 'mail'])|list }}"
  when: '"www." not in item[0] and item[0] not in uberspace_domains'
  command: uberspace {{ item[1] }} domain del {{ item[0] }}

- name: Remove old www domains
  loop: "{{ remote_domains|list }}"
  when: '"www." in item and item|replace("www.", "") not in uberspace_domains'
  command: uberspace web domain del {{ item }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants