Changeset - d44e023cf7bb
[Not reviewed]
0 10 0
Branko Majic (branko) - 4 years ago 2020-10-01 22:17:16
branko@majic.rs
MAR-155: Make the preseed_directory parameter in the preseed role mandatory:

- Updated the preseed role.
- Removed default value for the parameter.
- Updated tests.
- Updated role reference documentation.
- Updated release notes.
10 files changed with 14 insertions and 30 deletions:
0 comments (0 inline, 0 general)
docs/releasenotes.rst
Show inline comments
 
@@ -47,6 +47,10 @@ Breaking changes:
 
    dropped. This could introduce incompatibility with older clients
 
    trying to connect to the IMAP/SMTP server.
 

	
 
* ``preseed`` role
 

	
 
  * Parameter ``preseed_directory`` is now mandatory.
 

	
 
* ``web_server`` role
 

	
 
  * Use 2048-bit Diffie-Hellman parameters for relevant TLS
docs/rolereference.rst
Show inline comments
 
@@ -49,7 +49,7 @@ Parameters
 
**preseed_country** (string, optional, ``SE``)
 
  Country.
 

	
 
**preseed_directory** (string, optional, ``../preseed_files/``)
 
**preseed_directory** (string, mandatory)
 
  Destination directory where the preseed files should be stored.
 

	
 
  .. warning::
roles/preseed/defaults/main.yml
Show inline comments
 
@@ -2,7 +2,6 @@
 

	
 
ansible_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
 
preseed_country: SE
 
preseed_directory: "{{ inventory_dir }}/preseed_files"
 
preseed_keymap: us
 
preseed_language: en
 
preseed_locale: en_US.UTF-8
roles/preseed/molecule/default/group_vars/parameters-mandatory.yml
Show inline comments
 
---
 

	
 
preseed_directory: "/tmp/preseed_files/"
roles/preseed/molecule/default/group_vars/parameters-optional-with-overrides.yml
Show inline comments
 
---
 

	
 
preseed_directory: /tmp/custom_preseed_files_location
 
ansible_key: CUSTOMKEY
 
preseed_directory: "/tmp/preseed_files/"
 
preseed_server_overrides:
 
  parameters-optional-with-overrides-stretch64:
 
    country: RS
roles/preseed/molecule/default/group_vars/parameters-optional.yml
Show inline comments
 
@@ -2,7 +2,7 @@
 

	
 
ansible_key: CUSTOMKEY
 
preseed_country: RS
 
preseed_directory: /tmp/custom_preseed_files_location
 
preseed_directory: "/tmp/preseed_files/"
 
preseed_dns: 1.1.1.1
 
preseed_domain: example.com
 
preseed_gateway: 2.2.2.2
roles/preseed/molecule/default/prepare.yml
Show inline comments
 
@@ -8,17 +8,3 @@
 
      raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal)
 
      become: true
 
      changed_when: false
 

	
 
- hosts: parameters-mandatory
 
  become: true
 
  tasks:
 

	
 
    # @TODO: This is a hack because inventory_dir used for
 
    # preseed_directory comes from _host_.
 
    - name: Set-up inventory directory matching location where molecule is running itself
 
      file:
 
        path: "{{ inventory_dir }}"
 
        state: directory
 
        owner: vagrant
 
        group: vagrant
 
        mode: 0700
roles/preseed/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
import os
 
import pwd
 

	
 
import testinfra.utils.ansible_runner
 

	
 
@@ -15,12 +14,7 @@ def test_preseed_directory(host):
 

	
 
    with host.sudo():
 

	
 
        # Preseed directory created at same level as inventory.
 
        # @TODO: At this point, this path is getting uglier and
 
        #        uglier. It might be actually better to make the
 
        #        preseed_directory a mandatory parameter instead. Same
 
        #        goes for the ansible_key role parameter as well.
 
        preseed_directory_path = "%s/.cache/molecule/preseed/default/inventory/preseed_files" % pwd.getpwuid(os.getuid()).pw_dir
 
        preseed_directory_path = "/tmp/preseed_files"
 
        preseed_directory = host.file(preseed_directory_path)
 

	
 
        assert preseed_directory.is_directory
 
@@ -34,8 +28,7 @@ def test_preseed_configuration_files(host):
 

	
 
    with host.sudo():
 

	
 
        # Preseed directory created at same level as inventory.
 
        preseed_directory_path = "%s/.cache/molecule/preseed/default/inventory/preseed_files" % pwd.getpwuid(os.getuid()).pw_dir
 
        preseed_directory_path = "/tmp/preseed_files"
 

	
 
        # Verify that preseed configuration files are created for all hosts.
 
        for testinfra_host in testinfra_hosts:
 
@@ -54,7 +47,7 @@ def test_preseed_configuration_file_content(host):
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    with host.sudo():
 
        preseed_directory_path = "%s/.cache/molecule/preseed/default/inventory/preseed_files" % pwd.getpwuid(os.getuid()).pw_dir
 
        preseed_directory_path = "/tmp/preseed_files"
 
        preseed_file = host.file(os.path.join(preseed_directory_path, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = open(os.path.join(os.path.expanduser("~"), ".ssh", "id_rsa.pub")).read().strip()
roles/preseed/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -7,7 +7,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-optional')
 

	
 

	
 
PRESEED_DIRECTORY = '/tmp/custom_preseed_files_location'
 
PRESEED_DIRECTORY = '/tmp/preseed_files'
 

	
 

	
 
def test_preseed_directory(host):
roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py
Show inline comments
 
@@ -7,7 +7,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
 
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-optional-with-overrides')
 

	
 

	
 
PRESEED_DIRECTORY = '/tmp/custom_preseed_files_location'
 
PRESEED_DIRECTORY = '/tmp/preseed_files'
 

	
 

	
 
def test_preseed_directory(host):
0 comments (0 inline, 0 general)