saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

[BUG] mount.filesystems on AIX wrongly reports "options" attribute as "Invalid name for use in filesystems" #63121

Open st-voss opened 1 year ago

st-voss commented 1 year ago

Description On AIX a salt-ssh <aixminion> mount.filesystems to retrieve the stanzas of /etc/filesystems reports the following error when a stanza has an "options" attribute:

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: Invalid name for use in filesystems: options
Traceback (most recent call last):
  File "/tmp/salt-thin_dir/salt-call", line 27, in <module>
    salt_call()
...
  File "/tmp/salt-thin_dir/pyall/salt/modules/mount.py", line 1736, in filesystems
    ret_dict = _filesystems(config)
  File "/tmp/salt-thin_dir/pyall/salt/modules/mount.py", line 1699, in _filesystems
    lines, _FileSystemsEntry.compatibility_keys
  File "/tmp/salt-thin_dir/pyall/salt/modules/mount.py", line 540, in dict_from_lines
    "Invalid name for use in filesystems: {}".format(key_name)
ValueError: Invalid name for use in filesystems: options

For entries in /etc/filesystems on AIX an "options" attribute is perfectly legal and is also commonly used. See https://www.ibm.com/docs/en/aix/7.2?topic=files-filesystems-file for the allowed attributes of a stanza in /etc/filesystems.

Setup

Any AIX minion with a stanza in /etc/filesystems that has an "options" attribute. E.g.:

/mnt/foo:
        dev             = /dev/gaga
        vfs             = jfs2
        options         = rw,log=/dev/hd8
        mount           = False

Please be as specific as possible and give set-up details.

Steps to Reproduce the behavior

With stanza described above in /etc/filesystems do a salt call on any AIX minion:

# /usr/bin/python /tmp/salt-thin_dir/salt-call --local --out json  -c /tmp/salt-thin_dir -- mount.filesystems
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: Invalid name for use in filesystems: options
...

Expected behavior mount.filesystems should read and accept an "options" attribute in an /etc/filesystems stanza.

Screenshots If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ```yaml # /usr/bin/python /tmp/salt-thin_dir/salt-call --local -c /tmp/salt-thin_dir -- test.versions local: Salt Version: Salt: 3004.2 Dependency Versions: cffi: Not Installed cherrypy: Not Installed dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 2.10.3 libgit2: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack: 0.6.2 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: Not Installed pycrypto: Not Installed pycryptodome: 3.10.1 pygit2: Not Installed Python: 3.7.12 (default, Dec 15 2021, 03:25:47) python-gnupg: Not Installed PyYAML: 5.4.1 PyZMQ: 18.1.1 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.4 System Versions: dist: aix 2 locale: ISO8859-1 machine: 00XXXXXXXXXX release: 2 system: AIX version: AIX 2 ```

Additional context This is not a salt-ssh problem. Any salt <aixminon> mount.filesystems, salt-ssh <aixminon> mount.filesystems or salt-call --local mount.filesystems on an AIX minion would show the error

st-voss commented 1 year ago

Possible workaround/fix:

*** salt/modules/mount.py.ori   Fri Nov 25 10:38:57 2022
--- salt/modules/mount.py       Mon Nov 28 15:51:11 2022
***************
*** 486,492 ****
          Error raised when a line isn't parsible as an fstab entry
          """

!     filesystems_keys = ("device", "name", "fstype", "vfstype", "opts", "mount")

      # preserve data format of filesystems
      compatibility_keys = (
--- 486,492 ----
          Error raised when a line isn't parsible as an fstab entry
          """

!     filesystems_keys = ("device", "name", "fstype", "vfs", "options", "mount")

      # preserve data format of filesystems
      compatibility_keys = (