From 08f105c176a27b5ad6ac26119aad3c77f47173c0 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sat, 16 Mar 2019 08:55:42 +0000 Subject: [PATCH] Added ability to control no_log behavior This change makes the default behavior of molecule to enable logging of its tasks. This may expose credentials if they are defined in molecule.yml files. User can override this behaviour by defining MOLECULE_NO_LOG variable to true of false. When defined that value would override any value of `provider.log` mentioned inside molecule.yaml. When variable is not defined, the value from molecule.yml file will be used. When none of these are defined, logging will be enabled. This matches Ansible behavior where environment variables do take precedence over values defined in playbooks. Fixes: #1666 Signed-off-by: Sorin Sbarnea --- .flake8 | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- .../{{cookiecutter.scenario_name}}/create.yml | 2 +- .../destroy.yml | 2 +- molecule/provisioner/ansible.py | 3 +++ .../ansible/playbooks/docker/create.yml | 2 +- .../ansible/playbooks/docker/destroy.yml | 2 +- .../ansible/playbooks/lxd/create.yml | 2 +- .../ansible/playbooks/lxd/destroy.yml | 2 +- .../ansible/playbooks/vagrant/create.yml | 2 +- .../ansible/playbooks/vagrant/destroy.yml | 2 +- test/resources/playbooks/azure/create.yml | 2 +- test/resources/playbooks/azure/destroy.yml | 2 +- test/resources/playbooks/docker/create.yml | 2 +- test/resources/playbooks/docker/destroy.yml | 2 +- test/resources/playbooks/ec2/create.yml | 2 +- test/resources/playbooks/ec2/destroy.yml | 2 +- test/resources/playbooks/gce/create.yml | 2 +- test/resources/playbooks/gce/destroy.yml | 2 +- test/resources/playbooks/linode/create.yml | 2 +- test/resources/playbooks/linode/destroy.yml | 2 +- test/resources/playbooks/lxc/create.yml | 2 +- test/resources/playbooks/lxc/destroy.yml | 2 +- test/resources/playbooks/lxd/create.yml | 2 +- test/resources/playbooks/lxd/destroy.yml | 2 +- test/resources/playbooks/openstack/create.yml | 2 +- .../resources/playbooks/openstack/destroy.yml | 2 +- test/resources/playbooks/vagrant/create.yml | 2 +- test/resources/playbooks/vagrant/destroy.yml | 2 +- .../molecule/default/side_effect.yml | 2 +- test/unit/provisioner/test_ansible.py | 27 +++++++++++++++++++ 42 files changed, 70 insertions(+), 40 deletions(-) diff --git a/.flake8 b/.flake8 index dda1d77cdf..1922ce5ae4 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] exclude = .venv/,.tox/,dist/,build/,doc/,.eggs/,molecule/provisioner/ansible/plugins/libraries/goss.py format = pylint -ignore = E741,W503,W504 +ignore = E741,W503,W504,H diff --git a/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index c557755bb2..64aa61e2bb 100644 --- a/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: resource_group_name: molecule location: westus diff --git a/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index dd983b01c1..6ee0e21f73 100644 --- a/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/azure/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: resource_group_name: molecule tasks: diff --git a/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index ec387ee24f..cdf3f7595d 100644 --- a/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: # Developer must implement. diff --git a/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index d13448c454..4f5ef31996 100644 --- a/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/delegated/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: # Developer must implement. diff --git a/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index 0554041bab..789d9f6dbe 100644 --- a/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_user: ubuntu ssh_port: 22 diff --git a/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index f023429df5..8840746a42 100644 --- a/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - block: - name: Populate instance config diff --git a/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index 5fef0d73f7..36f11431a7 100644 --- a/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_port: 22 ssh_user: "{{ lookup('env', 'USER') }}" diff --git a/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index c4d9fe3d7b..69ff07828c 100644 --- a/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) gce: diff --git a/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index db70913d00..36abac1099 100644 --- a/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_user: root ssh_port: 22 diff --git a/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index 3550dfa8b3..830b539bed 100644 --- a/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/linode/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - block: - name: Populate instance config diff --git a/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index d9f8ef3b08..b23f764c41 100644 --- a/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Create molecule instance(s) lxc_container: diff --git a/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index 167b9e988c..a8b8371639 100644 --- a/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) lxc_container: diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml index 3c3ccc7efb..f564397e5f 100644 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_user: cloud-user ssh_port: 22 diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml index 8293fc53dc..b6b2650e37 100644 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml @@ -4,7 +4,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) os_server: diff --git a/molecule/provisioner/ansible.py b/molecule/provisioner/ansible.py index 7d942e9fc6..c067f49b4d 100644 --- a/molecule/provisioner/ansible.py +++ b/molecule/provisioner/ansible.py @@ -547,6 +547,9 @@ def inventory(self): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}" } # All group diff --git a/molecule/provisioner/ansible/playbooks/docker/create.yml b/molecule/provisioner/ansible/playbooks/docker/create.yml index b0b8d2bd27..cc7dd228b4 100644 --- a/molecule/provisioner/ansible/playbooks/docker/create.yml +++ b/molecule/provisioner/ansible/playbooks/docker/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Log into a Docker registry docker_login: diff --git a/molecule/provisioner/ansible/playbooks/docker/destroy.yml b/molecule/provisioner/ansible/playbooks/docker/destroy.yml index d4a8b751d2..4ef90279b5 100644 --- a/molecule/provisioner/ansible/playbooks/docker/destroy.yml +++ b/molecule/provisioner/ansible/playbooks/docker/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) docker_container: diff --git a/molecule/provisioner/ansible/playbooks/lxd/create.yml b/molecule/provisioner/ansible/playbooks/lxd/create.yml index 3728baf34c..fd944a1f39 100644 --- a/molecule/provisioner/ansible/playbooks/lxd/create.yml +++ b/molecule/provisioner/ansible/playbooks/lxd/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Create default source variable set_fact: diff --git a/molecule/provisioner/ansible/playbooks/lxd/destroy.yml b/molecule/provisioner/ansible/playbooks/lxd/destroy.yml index 3440d702dc..610766ee04 100644 --- a/molecule/provisioner/ansible/playbooks/lxd/destroy.yml +++ b/molecule/provisioner/ansible/playbooks/lxd/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) lxd_container: diff --git a/molecule/provisioner/ansible/playbooks/vagrant/create.yml b/molecule/provisioner/ansible/playbooks/vagrant/create.yml index 2fc021d551..536bcdf6d3 100644 --- a/molecule/provisioner/ansible/playbooks/vagrant/create.yml +++ b/molecule/provisioner/ansible/playbooks/vagrant/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Create molecule instance(s) molecule_vagrant: diff --git a/molecule/provisioner/ansible/playbooks/vagrant/destroy.yml b/molecule/provisioner/ansible/playbooks/vagrant/destroy.yml index 9b3b5e3a34..9f97e39055 100644 --- a/molecule/provisioner/ansible/playbooks/vagrant/destroy.yml +++ b/molecule/provisioner/ansible/playbooks/vagrant/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) molecule_vagrant: diff --git a/test/resources/playbooks/azure/create.yml b/test/resources/playbooks/azure/create.yml index 09a9a4f283..bd36900634 100644 --- a/test/resources/playbooks/azure/create.yml +++ b/test/resources/playbooks/azure/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: resource_group_name: molecule location: westus diff --git a/test/resources/playbooks/azure/destroy.yml b/test/resources/playbooks/azure/destroy.yml index 732c16ecc9..8ca07e1b5b 100644 --- a/test/resources/playbooks/azure/destroy.yml +++ b/test/resources/playbooks/azure/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: resource_group_name: molecule tasks: diff --git a/test/resources/playbooks/docker/create.yml b/test/resources/playbooks/docker/create.yml index 94b1ed6759..1317bc364b 100644 --- a/test/resources/playbooks/docker/create.yml +++ b/test/resources/playbooks/docker/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Log into a Docker registry docker_login: diff --git a/test/resources/playbooks/docker/destroy.yml b/test/resources/playbooks/docker/destroy.yml index d4a8b751d2..4ef90279b5 100644 --- a/test/resources/playbooks/docker/destroy.yml +++ b/test/resources/playbooks/docker/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) docker_container: diff --git a/test/resources/playbooks/ec2/create.yml b/test/resources/playbooks/ec2/create.yml index 4ed1a0c623..541c562c47 100644 --- a/test/resources/playbooks/ec2/create.yml +++ b/test/resources/playbooks/ec2/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_user: ubuntu ssh_port: 22 diff --git a/test/resources/playbooks/ec2/destroy.yml b/test/resources/playbooks/ec2/destroy.yml index d0f1ce83ca..79773c27e9 100644 --- a/test/resources/playbooks/ec2/destroy.yml +++ b/test/resources/playbooks/ec2/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: resource_group_name: molecule tasks: diff --git a/test/resources/playbooks/gce/create.yml b/test/resources/playbooks/gce/create.yml index a9fc543881..c95d3325ec 100644 --- a/test/resources/playbooks/gce/create.yml +++ b/test/resources/playbooks/gce/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_port: 22 ssh_user: "{{ lookup('env', 'USER') }}" diff --git a/test/resources/playbooks/gce/destroy.yml b/test/resources/playbooks/gce/destroy.yml index abe9cf0094..f22ae65f85 100644 --- a/test/resources/playbooks/gce/destroy.yml +++ b/test/resources/playbooks/gce/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) gce: diff --git a/test/resources/playbooks/linode/create.yml b/test/resources/playbooks/linode/create.yml index 7278f28548..7d4204dafe 100644 --- a/test/resources/playbooks/linode/create.yml +++ b/test/resources/playbooks/linode/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_user: root ssh_port: 22 diff --git a/test/resources/playbooks/linode/destroy.yml b/test/resources/playbooks/linode/destroy.yml index d1e7d8ef3d..64bb7b5231 100644 --- a/test/resources/playbooks/linode/destroy.yml +++ b/test/resources/playbooks/linode/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - block: - name: Populate instance config diff --git a/test/resources/playbooks/lxc/create.yml b/test/resources/playbooks/lxc/create.yml index 37e30c202b..823c0dcae6 100644 --- a/test/resources/playbooks/lxc/create.yml +++ b/test/resources/playbooks/lxc/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Create molecule instance(s) lxc_container: diff --git a/test/resources/playbooks/lxc/destroy.yml b/test/resources/playbooks/lxc/destroy.yml index f4ce249a82..2ea4529f26 100644 --- a/test/resources/playbooks/lxc/destroy.yml +++ b/test/resources/playbooks/lxc/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) lxc_container: diff --git a/test/resources/playbooks/lxd/create.yml b/test/resources/playbooks/lxd/create.yml index 3728baf34c..fd944a1f39 100644 --- a/test/resources/playbooks/lxd/create.yml +++ b/test/resources/playbooks/lxd/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Create default source variable set_fact: diff --git a/test/resources/playbooks/lxd/destroy.yml b/test/resources/playbooks/lxd/destroy.yml index 3440d702dc..610766ee04 100644 --- a/test/resources/playbooks/lxd/destroy.yml +++ b/test/resources/playbooks/lxd/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) lxd_container: diff --git a/test/resources/playbooks/openstack/create.yml b/test/resources/playbooks/openstack/create.yml index 24656b7cbc..4d0784c31c 100644 --- a/test/resources/playbooks/openstack/create.yml +++ b/test/resources/playbooks/openstack/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" vars: ssh_user: cloud-user ssh_port: 22 diff --git a/test/resources/playbooks/openstack/destroy.yml b/test/resources/playbooks/openstack/destroy.yml index 6dd783534b..f1d6043ee9 100644 --- a/test/resources/playbooks/openstack/destroy.yml +++ b/test/resources/playbooks/openstack/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) os_server: diff --git a/test/resources/playbooks/vagrant/create.yml b/test/resources/playbooks/vagrant/create.yml index 2fc021d551..536bcdf6d3 100644 --- a/test/resources/playbooks/vagrant/create.yml +++ b/test/resources/playbooks/vagrant/create.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Create molecule instance(s) molecule_vagrant: diff --git a/test/resources/playbooks/vagrant/destroy.yml b/test/resources/playbooks/vagrant/destroy.yml index 9b3b5e3a34..9f97e39055 100644 --- a/test/resources/playbooks/vagrant/destroy.yml +++ b/test/resources/playbooks/vagrant/destroy.yml @@ -3,7 +3,7 @@ hosts: localhost connection: local gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Destroy molecule instance(s) molecule_vagrant: diff --git a/test/scenarios/side_effect/molecule/default/side_effect.yml b/test/scenarios/side_effect/molecule/default/side_effect.yml index dee4ef09e1..6f40377626 100644 --- a/test/scenarios/side_effect/molecule/default/side_effect.yml +++ b/test/scenarios/side_effect/molecule/default/side_effect.yml @@ -2,7 +2,7 @@ - name: Side Effect hosts: all gather_facts: false - no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" + no_log: "{{ molecule_no_log }}" tasks: - name: Kill ntpd on target command: pkill ntpd diff --git a/test/unit/provisioner/test_ansible.py b/test/unit/provisioner/test_ansible.py index 17f1c3b9f3..a4fbd0e665 100644 --- a/test/unit/provisioner/test_ansible.py +++ b/test/unit/provisioner/test_ansible.py @@ -358,6 +358,9 @@ def test_inventory_property(_instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } }, 'all': { @@ -382,6 +385,9 @@ def test_inventory_property(_instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } }, 'foo': { @@ -424,6 +430,9 @@ def test_inventory_property(_instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } }, 'baz': { @@ -454,6 +463,9 @@ def test_inventory_property(_instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } } } @@ -503,6 +515,9 @@ def test_inventory_property_handles_missing_groups(temp_dir, _instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } } } @@ -844,6 +859,9 @@ def test_write_inventory(temp_dir, _instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } }, 'all': { @@ -868,6 +886,9 @@ def test_write_inventory(temp_dir, _instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } }, 'foo': { @@ -910,6 +931,9 @@ def test_write_inventory(temp_dir, _instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } }, 'baz': { @@ -940,6 +964,9 @@ def test_write_inventory(temp_dir, _instance): "{{ lookup('file', molecule_file) | molecule_from_yaml }}", 'molecule_instance_config': "{{ lookup('env', 'MOLECULE_INSTANCE_CONFIG') }}", + 'molecule_no_log': + "{{ lookup('env', 'MOLECULE_NO_LOG') or not " + "molecule_yml.provisioner.log|default(True) | bool }}", } } }