Files @ f05151d6f802
Branch filter:

Location: majic-ansible-roles/roles/php_website/tasks/main.yml - annotation

branko
MAR-132: Added support for Debian 9 (Stretch) to wsgi_website role:

- Set the shell for application system account explicitly (workaround
for Debian bug 865762 in Stretch).
- Updated Molecule tests to cover Debian 9.
- Updated Molecule test preparation playbook to account for a number
of differences between Jessie and Stretch (mainly related to mailing
functionality).
- Renamed a couple of variables in test for sending out mails to make
it clearer what is being looked up as part of regex matching.
- Updated Molecule tests where certain paths depend on what Debian
release they are ran against.
- Split-up Jessie-specific tests into separate file.
- Remove the /bin/ss utility instead of renaming it (testinfra socket
tests do not work with /bin/ss).
7727c37bce67
7727c37bce67
7727c37bce67
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
7727c37bce67
3af07319e2f3
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
14eb78a4f466
0f24d5b272f5
0f24d5b272f5
3af07319e2f3
e15b53d59517
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
7727c37bce67
7727c37bce67
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
14eb78a4f466
14eb78a4f466
0f24d5b272f5
0f24d5b272f5
ff510f233909
ff510f233909
ff510f233909
ff510f233909
7727c37bce67
3f2756d25f85
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
7727c37bce67
7727c37bce67
7727c37bce67
4a3c8915f967
4a3c8915f967
4a3c8915f967
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
4a3c8915f967
3f2756d25f85
0f24d5b272f5
0f24d5b272f5
14eb78a4f466
922cda0a1834
7727c37bce67
ff510f233909
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
ff510f233909
db91799cc8fa
3f2756d25f85
3dd7f39302f8
3dd7f39302f8
ff510f233909
ff510f233909
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
7727c37bce67
ff510f233909
7727c37bce67
d26fe0368a4b
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
0f24d5b272f5
d26fe0368a4b
d26fe0368a4b
d26fe0368a4b
d26fe0368a4b
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
3dd7f39302f8
0f24d5b272f5
d26fe0368a4b
d26fe0368a4b
d26fe0368a4b
aa2802e42d9d
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
aa2802e42d9d
3f2756d25f85
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
7727c37bce67
7727c37bce67
7727c37bce67
3f2756d25f85
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
0f24d5b272f5
7727c37bce67
7727c37bce67
7387caca37f3
7387caca37f3
7387caca37f3
7387caca37f3
7387caca37f3
7387caca37f3
---

- name: Create PHP website group
  group:
    name: "{{ user }}"
    gid: "{{ uid | default(omit) }}"
    state: present

- name: Create PHP website admin user
  user:
    name: "{{ admin }}"
    uid: "{{ admin_uid | default(omit) }}"
    group: "{{ user }}"
    shell: /bin/bash
    createhome: true
    home: "{{ home }}"
    state: present

- name: Set-up directory for storing user profile configuration files
  file:
    path: "{{ home }}/.profile.d"
    state: directory
    owner: "{{ admin }}"
    group: "{{ user }}"
    mode: 0750

- name: Create PHP website user
  user:
    name: "{{ user }}"
    uid: "{{ uid | default(omit) }}"
    group: "{{ user }}"
    comment: "umask=0007"
    system: true
    createhome: false
    state: present
    home: "{{ home }}"
    # This is a workaround for a rather stupid bug that Debian seems
    # uninterested to backport -
    # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=865762
    shell: /bin/sh

- name: Add nginx user to website group
  user:
    name: "www-data"
    groups: "{{ user }}"
    append: "yes"
  notify:
    - Restart nginx

# Ownership set to root so Postfix would not check if correct user owns the
# file.
- name: Set-up forwarding for mails delivered to local application user/admin
  template:
    src: "forward.j2"
    dest: "{{ home }}/.forward"
    owner: root
    group: "{{ user }}"
    mode: 0640

- name: Install extra packages for website
  apt:
    name: "{{ item }}"
    state: present
  with_items: "{{ packages }}"

- name: Set-up MariaDB mysql_config symbolic link for compatibility on Jessie (workaround for Debian bug 766996)
  file:
    src: "/usr/bin/mariadb_config"
    dest: "/usr/bin/mysql_config"
    state: link
  when: "'libmariadb-client-lgpl-dev-compat' in packages and ansible_distribution_release == 'jessie'"

- name: Deploy PHP FPM configuration file for website
  template:
    src: "fpm_site.conf.j2"
    dest: "{{ php_fpm_pool_directory }}/{{ fqdn }}.conf"
    validate: "{{ php_fpm_binary }} -t -y %s"
    owner: root
    group: root
    mode: 0640
  notify:
    - Restart PHP-FPM

- name: Deploy nginx TLS private key for website
  copy:
    dest: "/etc/ssl/private/{{ fqdn }}_https.key"
    content: "{{ https_tls_key }}"
    owner: root
    group: root
    mode: 0640
  notify:
    - Restart nginx

- name: Deploy nginx TLS certificate for website
  copy:
    dest: "/etc/ssl/certs/{{ fqdn }}_https.pem"
    content: "{{ https_tls_certificate }}"
    owner: root
    group: root
    mode: 0644
  notify:
    - Restart nginx

- name: Deploy configuration file for checking certificate validity via cron
  copy:
    content: "/etc/ssl/certs/{{ fqdn }}_https.pem"
    dest: "/etc/check_certificate/{{ fqdn }}_https.conf"
    owner: root
    group: root
    mode: 0644

- name: Deploy nginx configuration file for website
  template:
    src: "nginx_site.j2"
    dest: "/etc/nginx/sites-available/{{ fqdn }}"
    owner: root
    group: root
    mode: 0640
    validate: "/usr/local/bin/nginx_verify_site.sh -n '{{ fqdn }}' %s"
  notify:
    - Restart nginx

- name: Enable website
  file:
    src: "/etc/nginx/sites-available/{{ fqdn }}"
    dest: "/etc/nginx/sites-enabled/{{ fqdn }}"
    state: link
  notify:
    - Restart nginx

- name: Explicitly run all handlers
  include: ../handlers/main.yml
  when: "handlers | default(False) | bool() == True"
  tags:
    - handlers