Extract cloudflare_ddns user to a variable

This commit is contained in:
Thomas Kleinendorst 2024-04-12 09:10:43 +02:00
parent 5c5f1e4a93
commit 3ba044d1a2
4 changed files with 8 additions and 8 deletions

View file

@ -1,11 +1,9 @@
--- ---
- name: Read local vault
ansible.builtin.include_vars: vault.yml
- name: Create a new user - name: Create a new user
ansible.builtin.include_role: ansible.builtin.include_role:
name: user name: user
vars: vars:
username: cloudflare_ddns username: "{{ cloudflare_ddns_user }}"
password: "{{ cloudflare_ddns_user_password }}" password: "{{ cloudflare_ddns_user_password }}"
- name: Install Python dependencies # noqa: package-latest - name: Install Python dependencies # noqa: package-latest
become: true become: true
@ -14,14 +12,14 @@
state: latest state: latest
- name: Copy over DDNS scripting - name: Copy over DDNS scripting
become: true become: true
become_user: cloudflare_ddns become_user: "{{ cloudflare_ddns_user }}"
ansible.builtin.copy: ansible.builtin.copy:
src: cloudflare_ddns src: cloudflare_ddns
dest: ~/bin/ dest: ~/bin/
mode: '0700' mode: '0700'
- name: Configure Python venv - name: Configure Python venv
become: true become: true
become_user: cloudflare_ddns become_user: "{{ cloudflare_ddns_user }}"
ansible.builtin.shell: | ansible.builtin.shell: |
cd ~/bin/cloudflare_ddns cd ~/bin/cloudflare_ddns
python3 -m venv ./venv python3 -m venv ./venv
@ -33,14 +31,14 @@
creates: ~/bin/cloudflare_ddns/venv creates: ~/bin/cloudflare_ddns/venv
- name: Create directory for storing public IP change logs and config - name: Create directory for storing public IP change logs and config
become: true become: true
become_user: cloudflare_ddns become_user: "{{ cloudflare_ddns_user }}"
ansible.builtin.file: ansible.builtin.file:
path: ~/cloudflare_ddns path: ~/cloudflare_ddns
state: directory state: directory
mode: '0700' mode: '0700'
- name: Fill config file and store it in folder - name: Fill config file and store it in folder
become: true become: true
become_user: cloudflare_ddns become_user: "{{ cloudflare_ddns_user }}"
ansible.builtin.template: ansible.builtin.template:
src: ddns_config.ini.j2 src: ddns_config.ini.j2
dest: ~/cloudflare_ddns/ddns_config.ini dest: ~/cloudflare_ddns/ddns_config.ini

View file

@ -2,4 +2,4 @@
dns_cloudflare_token = {{ dns_cloudflare_token }} dns_cloudflare_token = {{ dns_cloudflare_token }}
[log_changes] [log_changes]
log_path = /home/cloudflare_ddns/cloudflare_ddns/ddns_update.log log_path = /home/{{ cloudflare_ddns_user }}/cloudflare_ddns/ddns_update.log

View file

@ -0,0 +1,2 @@
---
cloudflare_ddns_user: 'cloudflare_ddns'