Files @ 8944b8348567
Branch filter:

Location: majic-ansible-roles/roles/wsgi_website/molecule/default/playbook.yml

branko
MAR-226: Harmonise the HTTP header override parameter between the PHP and WSGI website roles:

- Use the new naming/syntax introduced in the php_website role since
it implies less dependence on the backend application (more generic
name for it), and is a little bit saner in terms of not having to
provide quotes as part of the value.
---

- hosts: wsgi-website
  become: true
  vars:
    # common
    ca_certificates:
      testca: "{{ lookup('file', 'tests/data/x509/ca/level1.cert.pem') }}"

    # web_server
    default_https_tls_certificate: "{{ lookup('file', 'tests/data/x509/server/wsgi-website_https.cert.pem') }}"
    default_https_tls_key: "{{ lookup('file', 'tests/data/x509/server/wsgi-website_https.key.pem') }}"

  roles:

    - role: wsgi_website
      fqdn: parameters-mandatory
      https_tls_certificate: "{{ lookup('file', 'tests/data/x509/server/parameters-mandatory_https.cert.pem') }}"
      https_tls_key: "{{ lookup('file', 'tests/data/x509/server/parameters-mandatory_https.key.pem') }}"
      wsgi_application: testapp:application

    - role: wsgi_website
      fqdn: parameters-optional.local
      https_tls_certificate: "{{ lookup('file', 'tests/data/x509/server/parameters-optional.local_https.cert.pem') }}"
      https_tls_key: "{{ lookup('file', 'tests/data/x509/server/parameters-optional.local_https.key.pem') }}"
      additional_nginx_config:
        - comment: Custom missing page.
          value: error_page 404 /my/own/error/page;
      admin_uid: 5000
      environment_indicator:
        background_colour: "#ff0000"
        text_colour: "#00ff00"
        text: "parameters-optional"
      environment_variables:
        MY_ENV_VAR: "My environment variable"
      packages:
        - atftp
        - global
      http_header_overrides:
        Accept-Encoding: ""
      rewrites:
        - '^/rewrite1/(.*) /rewritten1/ last'
        - '^/rewrite2/(.*) /rewritten2/$1 last'
      static_locations:
        - /static/
        - /media/
      uid: 5001
      use_paste: false
      virtualenv_packages:
        # Main packages.
        - dnspython==2.6.1
        - prompt-toolkit==3.0.43
        - ptpython==3.0.26
        # Dependencies.
        - appdirs==1.4.4
        - jedi==0.19.1
        - parso==0.8.3
        - pygments==2.17.2
        - wcwidth==0.2.13
      website_mail_recipients: user
      wsgi_application: testapp:application
      wsgi_requirements:
        - gunicorn==21.1.0
        - packaging==23.2
      wsgi_requirements_in:
        - gunicorn

    - role: wsgi_website
      fqdn: parameters-paste-req
      use_paste: true
      virtualenv_packages:
        # Main packages.
        - Flask==3.0.2
        - Paste==3.7.1
        - PasteDeploy==3.1.0
        # Dependencies.
        - Jinja2==3.1.3
        - MarkupSafe==2.1.5
        - Werkzeug==3.0.1
        - blinker==1.7.0
        - click==8.1.7
        - importlib-metadata==7.0.1
        - itsdangerous==2.1.2
        - six==1.16.0
        - zipp==3.17.0
      wsgi_application: config.ini
      wsgi_requirements:
        - gunicorn==21.1.0
        - packaging==23.2
      https_tls_certificate: "{{ lookup('file', 'tests/data/x509/server/parameters-paste-req_https.cert.pem') }}"
      https_tls_key: "{{ lookup('file', 'tests/data/x509/server/parameters-paste-req_https.key.pem') }}"

- hosts: wsgi-website
  become: true
  tasks:
    # parameters-mandatory application
    - name: Set-up directories where application files are hosted at
      file:
        path: "/var/www/parameters-mandatory/{{ item }}"
        state: directory
        owner: admin-parameters-mandatory
        group: web-parameters-mandatory
        mode: 02750
      with_items:
        - htdocs/static
        - htdocs/media
        - code
    - name: Deploy WSGI application
      copy:
        src: "tests/data/python/wsgi/testapp.py"
        dest: "/var/www/parameters-mandatory/code/testapp.py"
        owner: admin-parameters-mandatory
        group: web-parameters-mandatory
        mode: 0640
      notify:
        - Restart parameters-mandatory
    - name: Deploy a static file
      copy:
        src: "tests/data/static_file.txt"
        dest: "/var/www/parameters-mandatory/htdocs/static/static_file.txt"
        owner: admin-parameters-mandatory
        group: web-parameters-mandatory
        mode: 0640
    - name: Deploy a media file
      copy:
        src: "tests/data/media_file.txt"
        dest: "/var/www/parameters-mandatory/htdocs/media/media_file.txt"
        owner: admin-parameters-mandatory
        group: web-parameters-mandatory
        mode: 0640

    # parameters-optional application
    - name: Set-up directories where application files are hosted at
      file:
        path: "/var/www/parameters-optional.local/{{ item }}"
        state: directory
        owner: admin-parameters-optional_local
        group: web-parameters-optional_local
        mode: 02750
      with_items:
        - htdocs/static
        - htdocs/media
        - code
    - name: Deploy WSGI application
      copy:
        src: "tests/data/python/wsgi/testapp.py"
        dest: "/var/www/parameters-optional.local/code/testapp.py"
        owner: admin-parameters-optional_local
        group: web-parameters-optional_local
        mode: 0640
      notify:
        - Restart parameters-optional.local
    - name: Deploy a static file
      copy:
        src: "tests/data/static_file.txt"
        dest: "/var/www/parameters-optional.local/htdocs/static/static_file.txt"
        owner: admin-parameters-optional_local
        group: web-parameters-optional_local
        mode: 0640
    - name: Deploy a media file
      copy:
        src: "tests/data/media_file.txt"
        dest: "/var/www/parameters-optional.local/htdocs/media/media_file.txt"
        owner: admin-parameters-optional_local
        group: web-parameters-optional_local
        mode: 0640

    # parameters-paste-req application
    - name: Set-up directories where application files are hosted at
      file:
        path: "/var/www/parameters-paste-req/{{ item }}"
        state: directory
        owner: admin-parameters-paste-req
        group: web-parameters-paste-req
        mode: 02750
      with_items:
        - htdocs/static
        - htdocs/media
        - code
    - name: Deploy WSGI application
      copy:
        src: "tests/data/python/paste/{{ item }}"
        dest: "/var/www/parameters-paste-req/code/{{ item }}"
        owner: admin-parameters-paste-req
        group: web-parameters-paste-req
        mode: 0640
      with_items:
        - config.ini
        - testapp.py
        - wsgi.py
      notify:
        - Restart parameters-paste-req
    - name: Deploy a static file
      copy:
        src: "tests/data/static_file.txt"
        dest: "/var/www/parameters-paste-req/htdocs/static/static_file.txt"
        owner: admin-parameters-paste-req
        group: web-parameters-paste-req
        mode: 0640
    - name: Deploy a media file
      copy:
        src: "tests/data/media_file.txt"
        dest: "/var/www/parameters-paste-req/htdocs/media/media_file.txt"
        owner: admin-parameters-paste-req
        group: web-parameters-paste-req
        mode: 0640

  handlers:
    - name: Restart parameters-mandatory
      service:
        name: parameters-mandatory
        state: restarted
    - name: Restart parameters-optional.local
      service:
        name: parameters-optional.local
        state: restarted
    - name: Restart parameters-paste-req
      service:
        name: parameters-paste-req
        state: restarted