diff --git a/library/roles/powerdns-admin/defaults/main.yml b/library/roles/powerdns-admin/defaults/main.yml index 4e49c219..7d480d3d 100644 --- a/library/roles/powerdns-admin/defaults/main.yml +++ b/library/roles/powerdns-admin/defaults/main.yml @@ -16,6 +16,8 @@ pdns_admin_prereqs: - python3 - python3-pip - python3-virtualenv + - virtualenv + - python3-psycopg2 - python3-dev - libmysqlclient-dev - libxmlsec1-dev @@ -24,4 +26,3 @@ pdns_admin_prereqs: - libsasl2-dev - libldap2-dev - libssl-dev - - python3-psycopg2 \ No newline at end of file diff --git a/library/roles/powerdns-admin/meta/main.yml b/library/roles/powerdns-admin/meta/main.yml index f1749521..a60de378 100644 --- a/library/roles/powerdns-admin/meta/main.yml +++ b/library/roles/powerdns-admin/meta/main.yml @@ -1,3 +1,4 @@ --- dependencies: - role: '../../library/roles/nginx' + - role: '../../library/roles/node_js' diff --git a/library/roles/powerdns-admin/tasks/main.yml b/library/roles/powerdns-admin/tasks/main.yml index dc684a85..84b5175b 100644 --- a/library/roles/powerdns-admin/tasks/main.yml +++ b/library/roles/powerdns-admin/tasks/main.yml @@ -14,8 +14,7 @@ - '{{ pdns_admin_logdir }}' - name: Install the pdns_admin prerequisite deb packages - apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=1800 - with_items: '{{ pdns_admin_prereqs }}' + apt: pkg={{ pdns_admin_prereqs }} state=present update_cache=yes cache_valid_time=1800 - name: Clone pdns_admin git: repo={{ pdns_admin_git_repo_url }} dest={{ pdns_admin_home }} @@ -24,7 +23,7 @@ file: dest={{ pdns_admin_home }}/upload recurse=yes owner={{ pdns_admin_user }} group={{ pdns_admin_user }} - name: Install the pdns_admin configuration - template: src=config.py dest={{ pdns_admin_home }}/config.py + template: src=config.py dest={{ pdns_admin_home }}/config.py owner=root group={{ pdns_admin_user }} mode=0640 notify: Restart pdns_admin - name: Create a python3 virtualenv @@ -42,10 +41,21 @@ notify: Restart pdns_admin - name: Initialise the database - shell: cd {{ pdns_admin_home }}; . {{ pdns_admin_home }}/flask/bin/activate ; ./create_db.py ; touch {{ pdns_admin_logdir }}/.db_initialised + shell: cd {{ pdns_admin_home }}; . {{ pdns_admin_home }}/flask/bin/activate ; export FLASK_APP=app/__init__.py ; flask db upgrade && touch {{ pdns_admin_logdir }}/.db_initialised args: creates: '{{ pdns_admin_logdir }}/.db_initialised' + - name: Create the assets files + shell: cd {{ pdns_admin_home }}; . {{ pdns_admin_home }}/flask/bin/activate ; yarn install --pure-lockfile ; flask assets build + args: + creates: '{{ pdns_admin_home }}/app/static/generated/login.js' + + - name: Some directories must be writeable by the pdnsadmin user + file: dest={{ item }} recurse=yes owner={{ pdns_admin_user }} group={{ pdns_admin_user }} + with_items: + - '{{ pdns_admin_home }}/app/static/custom' + - '{{ pdns_admin_home }}/app/static/.webassets-cache' + - name: Install the pdns_admin server systemd unit template: src=powerdns-admin.service dest=/etc/systemd/system/powerdns-admin.service mode=0644 owner=root group=root when: ansible_service_mgr == 'systemd' diff --git a/library/roles/powerdns-admin/vars/main.yml b/library/roles/powerdns-admin/vars/main.yml index 945e4fb8..c92b81ea 100644 --- a/library/roles/powerdns-admin/vars/main.yml +++ b/library/roles/powerdns-admin/vars/main.yml @@ -1,6 +1,10 @@ --- http_port: 80 https_port: 443 + +node_js_repo_version: 10 +node_js_yarn_install: True + nginx_letsencrypt_managed: True nginx_use_common_virthost: True nginx_virthosts: