12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- - name: Create temporary fathom directory
- file: state=directory path=/root/fathom
-
- - name: Download fathom {{ fathom_version }} release
- get_url:
- url="{{ fathom_release }}"
- dest=/root/fathom/fathom-{{ fathom_version }}.tar.gz
-
- - name: Decompress fathom release
- unarchive: src=/root/fathom/fathom-{{ fathom_version }}.tar.gz
- dest=/root/fathom copy=no
- creates=/root/fathom/fathom
-
- - name: Create /usr/local/bin
- file: state=directory path=/usr/local/bin
-
- - name: Stop old fathom instance
- service: name=fathom-stats state=stopped
-
- - name: Copy fathom binary to /usr/local/bin
- shell: cp fathom/fathom /usr/local/bin/fathom chdir=/root
-
- - name: Remove downloaded temporary fathom files
- file: state=absent path=/root/fathom
-
- - name: Create fathom working directory
- file: state=directory path=/home/{{ main_user_name }}/fathom-stats
-
- - name: Create fathom config file
- template:
- src=home_user_fathom-stats_env.j2
- dest=/home/{{ main_user_name }}/fathom-stats/.env
- owner={{ main_user_name }}
- group=root
-
- - name: Add fathom postgres user
- postgresql_user:
- login_host=localhost
- login_user={{ db_admin_username }}
- login_password="{{ db_admin_password }}"
- name={{ fathom_db_username }}
- password="{{ fathom_db_password }}"
- encrypted=yes
- state=present
-
- - name: Create fathom database
- postgresql_db:
- login_host=localhost
- login_user={{ db_admin_username }}
- login_password="{{ db_admin_password }}"
- name={{ fathom_db_database }}
- state=present
- owner={{ fathom_db_username }}
-
- - name: Delete old fathom admin user account
- become: true
- become_user: "{{ main_user_name }}"
- shell: fathom user delete --email="{{ fathom_admin_username }}"
- args:
- chdir: /home/{{ main_user_name }}/fathom-stats
-
- - name: Create fathom admin user account
- become: true
- become_user: "{{ main_user_name }}"
- shell: fathom user add --email="{{ fathom_admin_username }}" --password="{{ fathom_admin_password }}"
- args:
- chdir: /home/{{ main_user_name }}/fathom-stats
-
- - name: Add systemd service to start fathom automatically
- template:
- src=etc_systemd_system_fathom-stats.j2
- dest=/etc/systemd/system/fathom-stats.service
- owner=root
- group=root
-
- - name: Register new fathom service
- systemd: name=fathom-stats daemon_reload=yes enabled=yes
-
- - name: Start new fathom instance
- service: name=fathom-stats state=started
-
- - name: Create the Apache Fathom sites config files
- template:
- src=etc_apache2_sites-available_fathom.j2
- dest=/etc/apache2/sites-available/fathom_{{ item.name }}.conf
- owner=root
- group=root
- with_items: "{{ virtual_domains }}"
-
- - name: Remove old sites-enabled symlinks (new ones will be created by a2ensite)
- file: path=/etc/apache2/sites-enabled/fathom_{{ item }}.conf state=absent
- with_items: "{{ virtual_domains | json_query('[*].name') }}"
-
- - name: Enable Apache sites (creates new sites-enabled symlinks)
- command: a2ensite fathom_{{ item }}.conf creates=/etc/apache2/sites-enabled/fathom_{{ item }}.conf
- notify: restart apache
- with_items: "{{ virtual_domains | json_query('[*].name') }}"
|