123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- - name: Install gpodder dependencies
- apt:
- name: "{{ packages }}"
- state: present
- vars:
- packages:
- - libpq-dev
- - libjpeg-dev
- - zlib1g-dev
- - libwebp-dev
- - build-essential
- - python3-dev
- - virtualenv
- - libffi-dev
- tags:
- - dependencies
-
- - name: Add gpodder user
- user:
- name: gpodder
- home: /home/gpodder
- create_home: yes
- shell: /bin/bash
- password_lock: yes
- state: present
- system: yes
-
- - name: Add gpodder postgres user
- postgresql_user:
- login_host=localhost
- login_user={{ db_admin_username }}
- login_password="{{ db_admin_password }}"
- name={{ gpodder_db_username }}
- password="{{ gpodder_db_password }}"
- encrypted=yes
- state=present
-
- - name: Create gpodder database
- postgresql_db:
- login_host=localhost
- login_user={{ db_admin_username }}
- login_password="{{ db_admin_password }}"
- name={{ gpodder_db_database }}
- state=present
- owner={{ gpodder_db_username }}
-
- - name: Download gpodder {{ gpodder_version }} release
- get_url:
- url="{{ gpodder_release }}"
- dest=/home/gpodder/gpodder-{{ gpodder_version }}.zip
-
- - name: Stop old gpodder instance
- service: name=gpodder state=stopped
- ignore_errors: True
-
- - name: Stop old gpodder worker instance
- service: name=gpodder_worker state=stopped
- ignore_errors: True
-
- - name: Stop old gpodder beat instance
- service: name=gpodder_beat state=stopped
- ignore_errors: True
-
- - name: Remove old gpodder directory
- shell: rm -rf /home/gpodder/gpodder
-
- - name: Create gpodder directory
- file: state=directory path=/home/gpodder/gpodder
-
- - name: Extract gpodder sources
- unarchive:
- src: /home/gpodder/gpodder-{{ gpodder_version }}.zip
- dest: /home/gpodder/gpodder
- remote_src: yes
-
- - name: Move sources in correct place
- shell: mv mygpo-{{ gpodder_version }}/* . chdir=/home/gpodder/gpodder
-
- - name: Remove empty directory
- shell: rm -rf /home/gpodder/gpodder/mygpo-{{ gpodder_version }}
-
- - name: Create virtualenv
- shell: virtualenv venv chdir=/home/gpodder/gpodder
-
- - name: Install generic dependencies in virtualenv
- shell: bash -c 'source venv/bin/activate && pip install -r requirements.txt' chdir=/home/gpodder/gpodder
-
- - name: Install dependencies for production in virtualenv
- shell: bash -c 'source venv/bin/activate && pip install -r requirements-setup.txt' chdir=/home/gpodder/gpodder
-
- - name: Create gpodder logs directory
- file: state=directory path=/home/gpodder/logs owner=gpodder group=gpodder
-
- - name: Create gpodder media directory
- file:
- state: directory
- path: "/data/gpodder"
- owner: gpodder
- group: gpodder
- mode: 0750
-
- - name: Add gpodder wrapper script
- template:
- src=home_gpodder_env.j2
- dest=/home/gpodder/env.sh
- owner=gpodder
- group=gpodder
- mode=0750
-
- - name: Fix ownership of installed files
- shell: chown -R gpodder:gpodder /home/gpodder/gpodder
-
- - name: Run collecting script for static files
- become: true
- become_user: gpodder
- shell: ./env.sh python manage.py collectstatic --no-input chdir=/home/gpodder
-
- #- name: Run compiling script for messages
- # become: true
- # become_user: gpodder
- # shell: ./env.sh python manage.py compilemessages chdir=/home/gpodder
-
- - name: Run database migration script
- become: true
- become_user: gpodder
- shell: ./env.sh python manage.py migrate chdir=/home/gpodder
-
- - name: Add systemd service to start gpodder automatically
- template:
- src=etc_systemd_system_gpodder.j2
- dest=/etc/systemd/system/gpodder.service
- owner=root
- group=root
-
- - name: Add systemd service to start gpodder worker automatically
- template:
- src=etc_systemd_system_gpodder_worker.j2
- dest=/etc/systemd/system/gpodder_worker.service
- owner=root
- group=root
-
- - name: Add systemd service to start gpodder beat automatically
- template:
- src=etc_systemd_system_gpodder_beat.j2
- dest=/etc/systemd/system/gpodder_beat.service
- owner=root
- group=root
-
- - name: Register new gpodder service
- systemd: name=gpodder daemon_reload=yes enabled=yes
-
- - name: Register new gpodder worker service
- systemd: name=gpodder_worker daemon_reload=yes enabled=yes
-
- - name: Register new gpodder beat service
- systemd: name=gpodder_beat daemon_reload=yes enabled=yes
-
- - name: Start new gpodder instance
- service: name=gpodder state=started
-
- - name: Start new gpodder worker instance
- service: name=gpodder_worker state=started
-
- - name: Start new gpodder beat instance
- service: name=gpodder_beat state=started
-
- # TODO cron jobs
- # envdir envs/dev python manage.py update-toplist
- # envdir envs/dev python manage.py update-episode-toplist
-
- # envdir envs/dev python manage.py feed-downloader
- # envdir envs/dev python manage.py feed-downloader <feed-url> [...]
- # envdir envs/dev python manage.py feed-downloader --max <max-updates>
- # envdir envs/dev python manage.py feed-downloader --random --max <max-updates>
- # envdir envs/dev python manage.py feed-downloader --toplist --max <max-updates>
- # envdir envs/dev python manage.py feed-downloader --update-new --max <max-updates>
-
- - name: Configure gpodder logrotate
- copy:
- src=etc_logrotate_gpodder
- dest=/etc/logrotate.d/gpodder
- owner=root
- group=root
- mode=0644
-
- - name: Create the Apache gpodder sites config files
- template:
- src=etc_apache2_sites-available_gpodder.j2
- dest=/etc/apache2/sites-available/gpodder_{{ item.name }}.conf
- owner=root
- group=root
- with_items: "{{ virtual_domains }}"
-
- - name: Enable Apache sites (creates new sites-enabled symlinks)
- command: a2ensite gpodder_{{ item }}.conf creates=/etc/apache2/sites-enabled/gpodder_{{ item }}.conf
- notify: restart apache
- with_items: "{{ virtual_domains | json_query('[*].name') }}"
|