Skip to content

[BUG] in vhosts/standard.sls the map.pop affects the apache variable as well because it is a reference, not a copy #377

@doubletwist13

Description

@doubletwist13

Your setup

Formula commit hash / release tag

apache-formula 1.2.2

Versions reports (master & minion)

          Salt: 3004
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: unknown
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: 0.6.4
     gitpython: 1.0.1
        Jinja2: 2.11.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 18 2021, 10:07:16)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 17.0.0
         smmap: 0.9.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4
 
System Versions:
          dist: oracle 7.9 
        locale: UTF-8
       machine: x86_64
       release: 5.4.17-2136.302.6.1.el7uek.x86_64
        system: Linux
       version: Oracle Linux Server 7.9 

Pillar / config used

apache:
  sites:
    example.com_redirect:
      port: '80'
      ServerName: example.com
      RedirectSource: '/'
      RedirectTarget: 'https://example.com'
    example.com_ssl:
      port: '443'
      ServerName: example.com
      DocumentRoot: /path/to/webroot
        

Bug details

Describe the bug

In apache/config/vhosts/standard.sls lines 8-11 attempt to make a copy of the 'apache' variable to 'map' and then trim to only include the 'sites' data but instead of making a copy it just makes a reference. This causes the map.pop to trim the 'apache' variable as well as the 'map' variable.

Steps to reproduce the bug

Expected behaviour

map.pop should trim only the 'map' variable, not the 'apache' variable.

Attempts to fix the bug

Just need to tell it to copy the variable instead of creating a reference by changing from:

{%- set map = apache %}
{%- do map.pop('sites', None) %}

TO

{%- set map = apache.copy() %}
{%- do map.pop('sites', None) %}

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions