salt icon indicating copy to clipboard operation
salt copied to clipboard

pkgrepo.managed: Invalid syntax when using [options]

Open phil-lavin opened this issue 10 years ago • 5 comments

When using the optional options parameter when adding an apt repository, a stray closing ] is added, causing a syntax error in the apt config.

Setup

{% for dist, config in salt['pillar.get']('repo', {}).iteritems() %}
install_our_repo:
  pkgrepo.managed:
    - humanname: our-repo
    - name: deb [arch=amd64 trusted=yes] http://{{ config.hostname }}/ {{ dist }} main contrib
    - file: /etc/apt/sources.list.d/platform-repository.list

{% endfor %}

Steps to Reproduce Issue

Run the above SLS. The file that is created comes out as:

deb [arch=amd64] trusted=yes] http://repository.staging.synety.local contrib main staging

There is a stray closing ] added

Versions Report

Master:

Salt Version:
           Salt: 2015.8.8.2

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
         Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: debian 8.3
        machine: x86_64
        release: 3.16.0-4-amd64
         system: debian 8.3

Minion:

Salt Version:
           Salt: 2015.8.8.2

Dependency Versions:
         Jinja2: 2.6
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.10
          PyZMQ: 13.1.0
         Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 3.2.3
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: debian 7.8
        machine: x86_64
        release: 3.2.0-4-amd64
         system: debian 7.8

phil-lavin avatar Apr 05 '16 16:04 phil-lavin

@phil-lavin, thanks for reporting.

jfindlay avatar Apr 05 '16 16:04 jfindlay

To add some more context, this only happens on Debian 7 minions. Debian 8 minions running the same version configure correctly. Output from a working Debian 8 minion is below:

phil@backend-lb-01:~$ salt-minion --versions-report
Salt Version:
           Salt: 2015.8.8.2

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
         Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: debian 8.3
        machine: x86_64
        release: 3.16.0-4-amd64
         system: debian 8.3

phil-lavin avatar Apr 05 '16 16:04 phil-lavin

It is bug in python-apt package in Debian 7 - aptsources module

Debian 7

# python
Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from aptsources import sourceslist
>>> repo = 'deb [arch=amd64 trusted=yes] http://example.com/ wheezy  main contrib'
>>> split = sourceslist.SourceEntry(repo)
>>> print(split.type, split.uri, split.dist, split.comps
... )
('deb', 'trusted=yes]', 'http://example.com/', ['wheezy', 'main', 'contrib'])

Debian 8

# python
Python 2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from aptsources import sourceslist
>>> repo = 'deb [arch=amd64 trusted=yes] http://example.com/ wheezy  main contrib'
>>> split = sourceslist.SourceEntry(repo)
>>> print(split.type, split.uri, split.dist, split.comps
... )
('deb', 'http://example.com/', 'wheezy', ['main', 'contrib'])

samodid avatar Nov 10 '17 19:11 samodid

As the bug was not in Salt, and has since been fixed in Debian 8, (Debian 7 is no longer supported as of May 2018) this bug should probably be closed.

@terminalmage , could you close this please? Thanks.

lordcirth avatar Jan 04 '19 19:01 lordcirth

Thanks for the heads-up!

terminalmage avatar Jan 10 '19 15:01 terminalmage