Changeset - 14eb78a4f466
[Not reviewed]
0 11 0
Branko Majic (branko) - 6 years ago 2018-06-03 10:19:04
branko@majic.rs
MAR-129: Updated php_website role for Ansible 2.5.x and new Molecule:

- Include global linting configuration file in tests.
- Fixed linting issues.
- Fix deprecation warnings from Ansible (for apt module and
state=installed).
- Updated how the hosts are being referenced within tests.
11 files changed with 29 insertions and 25 deletions:
0 comments (0 inline, 0 general)
roles/php_website/defaults/main.yml
Show inline comments
 
@@ -2,7 +2,7 @@
 

	
 
additional_nginx_config: {}
 
deny_files_regex: []
 
enforce_https: True
 
enforce_https: true
 
index: index.php
 
packages: []
 
php_file_regex: \.php$
roles/php_website/meta/main.yml
Show inline comments
 
---
 

	
 
allow_duplicates: yes
 
allow_duplicates: true
 

	
 
dependencies:
 
  - common
roles/php_website/molecule/default/create.yml
Show inline comments
 
@@ -2,7 +2,7 @@
 
- name: Create
 
  hosts: localhost
 
  connection: local
 
  gather_facts: False
 
  gather_facts: false
 
  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
 
  vars:
 
    molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
roles/php_website/molecule/default/destroy.yml
Show inline comments
 
@@ -3,7 +3,7 @@
 
- name: Destroy
 
  hosts: localhost
 
  connection: local
 
  gather_facts: False
 
  gather_facts: false
 
  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
 
  vars:
 
    molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
roles/php_website/molecule/default/molecule.yml
Show inline comments
 
@@ -9,6 +9,8 @@ driver:
 

	
 
lint:
 
  name: yamllint
 
  options:
 
    config-file: ../../.yamllint.yml
 

	
 
platforms:
 

	
roles/php_website/molecule/default/playbook.yml
Show inline comments
 
---
 

	
 
- hosts: all
 
  become: yes
 
  become: true
 
  vars:
 
    # common
 
    ca_certificates:
 
@@ -29,7 +29,7 @@
 
      admin_uid: 5000
 
      deny_files_regex:
 
        - '^/secretfile.txt'
 
      enforce_https: no
 
      enforce_https: false
 
      environment_indicator:
 
        background_colour: "#ff0000"
 
        text_colour: "#00ff00"
 
@@ -53,7 +53,7 @@
 
      website_mail_recipients: user
 

	
 
- hosts: all
 
  become: yes
 
  become: true
 
  tasks:
 
    # parameters-mandatory application
 
    - name: Set-up directory where PHP files are hosted at
roles/php_website/molecule/default/prepare.yml
Show inline comments
 
@@ -2,21 +2,21 @@
 

	
 
- name: Prepare
 
  hosts: all
 
  gather_facts: False
 
  gather_facts: false
 
  tasks:
 
    - name: Install python for Ansible
 
      raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
 
      become: True
 
      changed_when: False
 
      become: true
 
      changed_when: false
 

	
 
- hosts: all
 
  become: yes
 
  become: true
 
  tasks:
 

	
 
    - name: Update all caches to avoid errors due to missing remote archives
 
      apt:
 
        update_cache: yes
 
      changed_when: False
 
        update_cache: true
 
      changed_when: false
 

	
 
    - name: Set-up /etc/hosts entries
 
      lineinfile:
 
@@ -26,17 +26,17 @@
 
    - name: Install curl for testing redirects and webpage content
 
      apt:
 
        name: curl
 
        state: installed
 
        state: present
 

	
 
    - name: Install swaks for testing mail forwarding
 
      apt:
 
        name: swaks
 
        state: installed
 
        state: present
 

	
 
    - name: Install Postfix for testing mail forwarding (Exim4 not covered)
 
      apt:
 
        name: postfix
 
        state: installed
 
        state: present
 

	
 
    - name: Set-up group for an additional user
 
      group:
roles/php_website/molecule/default/tests/test_default.py
Show inline comments
 
import os
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('all')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['all'])
roles/php_website/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
import os
 
import re
 
import time
 

	
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('all')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['all'])
 

	
 

	
 
def test_website_group(host):
roles/php_website/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
import os
 
import re
 
import time
 

	
 

	
 
import testinfra.utils.ansible_runner
 

	
 

	
 
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    '.molecule/ansible_inventory.yml').get_hosts('all')
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['all'])
 

	
 

	
 
def test_website_group(host):
roles/php_website/tasks/main.yml
Show inline comments
 
@@ -12,7 +12,7 @@
 
    uid: "{{ admin_uid | default(omit) }}"
 
    group: "{{ user }}"
 
    shell: /bin/bash
 
    createhome: yes
 
    createhome: true
 
    home: "{{ home }}"
 
    state: present
 

	
 
@@ -30,8 +30,8 @@
 
    uid: "{{ uid | default(omit) }}"
 
    group: "{{ user }}"
 
    comment: "umask=0007"
 
    system: yes
 
    createhome: no
 
    system: true
 
    createhome: false
 
    state: present
 
    home: "{{ home }}"
 

	
 
@@ -56,7 +56,7 @@
 
- name: Install extra packages for website
 
  apt:
 
    name: "{{ item }}"
 
    state: installed
 
    state: present
 
  with_items: "{{ packages }}"
 

	
 
- name: Set-up MariaDB mysql_config symbolic link for compatibility (workaround for Debian bug 766996)
0 comments (0 inline, 0 general)