Repository navigation
Closed
Labels
Featurenew functionality including changes to functionality and code refactors, etc.PlatformRelates to OS, containers, platform-based utilities like FS, system based appspending-discussionThe issue or pull request needs more discussion before it can be closed or mergedstale
Milestone
Description
As mentioned by @damon-atkins in PR #30414
There are indeed lots of ways modules get named, below is a table of what we currently have and what there virtualname is.
| filename | virtualname | loaded |
|---|---|---|
| bsd_shadow.py | shadow | os = %BSD% |
| darwin_pkgutil.py | darwin_pkgutil | os = MacOS |
| darwin_sysctl.py | sysctl | os = MacOS |
| deb_apache.py | apache | os_family = Debian |
| deb_postgres.py | postgres | which = pg_createcluster |
| debian_ip.py | ip | os_family = Debian |
| debian_service.py | service | os in ('Debian', 'Raspbian', 'Devuan') |
| freebsd_sysctl.py | sysctl | os = FreeBSD |
| freebsdjail.py | jail | os = FreeBSD |
| freebsdkmod.py | kmod | kernel = FreeBSD |
| freebsdpkg.py | pkg | os = FreeBSD and os_release > 10 |
| freebsdports.py | ports | os = FreeBSD |
| freebsdservice.py | service | os = FreeBSD |
| gentoo_service.py | service | os = Gentoo |
| linux_acl.py | acl | which = getfacl |
| linux_ip.py | ip | which = ip and not os_family in ('Debian', 'RedHat') |
| linux_lvm.py | lvm | which = lvm |
| linux_sysctl.py | sysctl | kernel = Linux |
| mac_group.py | group | kernel = Darwin and os_releaseinfo > (10, 7) |
| mac_shadow.py | shadow | salt.utils.is_darwin |
| mac_softwareupdate.py | softwareupdate | salt.utils.is_darwin |
| mac_timezone.py | timezone | salt.utils.is_darwin |
| mac_user.py | user | kernel = Darwin and os_releaseinfo > (10, 7) |
| netbsd_sysctl.py | sysctl | os = NetBSD |
| netbsdservice.py | service | os = NetBSD and path /etc/rc.subr |
| openbsd_sysctl.py | sysctl | os = OpenBSD |
| openbsdpkg.py | pkg | os = OpenBSD |
| openbsdservice.py | service | os = OpenBSD and path /etc/rc.d/rc.subr and not path /usr/sbin/rcctl |
| openbsdrcctl.py | service | os = OpenBSD and path /usr/sbin/rcctl |
| osxdesktop.py | desktop | salt.utils.is_darwin |
| rh_ip.py | ip | os_family = RedHat |
| smartos_imgadm.py | imgadm | salt.utils.is_smartos_globalzone and which = imgadm |
| smartos_virt.py | virst | vmadm in modules |
| smartos_vmadm.py | vmadm | salt.utils.is_smartos_globalzone and which = vmadm |
| solaris_fmadm.py | fmadm | salt.utils.is_sunos() and which = fmdump and which = fmadm |
| solaris_group.py | group | kernel = SunOS |
| solaris_shadow.py | shadow | kernel = SunOS |
| solaris_system.py | system | salt.utils.is_sunos and which = shutdown |
| solaris_user.py | user | kernel = SunOS and HAS_PWD |
| solarisips.py | pkg | kernel = SunOS and kernelrelease > 5.10 |
| solarispkg.py | pkg | kernel = SunOS and kernelrelease <= 5.10 |
| win_autoruns.py | autoruns | salt.utils.is_windows |
| win_dacl.py | win_dacl | salt.utils.is_windows and HAS_WINDOWS_MODULES |
| win_disk.py | disk | salt.utils.is_windows |
| win_dns_client.py | win_dns_client | salt.utils.is_windows |
| win_dsc.py | dsc | salt.utils.is_windows |
| win_file.py | file | salt.utils.is_windows and HAS_WINDOWS_MODULES |
| win_firewall.py | firewall | salt.utils.is_windows |
| win_groupadd.py | group | salt.utils.is_windows and HAS_DEPENDENCIES |
| win_iis.py | win_iis | salt.utils.is_windows |
| win_ip.py | ip | salt.utils.is_windows |
| win_network.py | network | salt.utils.is_windows and HAS_DEPENDENCIES |
| win_ntp.py | ntp | salt.utils.is_windows |
| win_path.py | win_path | salt.utils.is_windows and HAS_WIN32 |
| win_pkg.py | pkg | salt.utils.is_windows and HAS_DEPENDENCIES |
| win_powercfg.py | powercfg | os = Windows |
| win_repo.py | winrepo | salt.utils.is_windows |
| win_servermanager.py | win_servermanager | salt.utils.is_windows |
| win_service.py | service | salt.utils.is_windows |
| win_shadow.py | shadow | salt.utils.is_windows |
| win_status.py | status | salt.utils.is_windows and has_required_packages: |
| win_system.py | system | salt.utils.is_windows and HAS_WIN32NET_MODS |
| win_task.py | task | salt.utils.is_windows and HAS_DEPENDENCIES |
| win_timezone.py | timezone | salt.utils.is_windows and which = tzutil |
| win_update.py | update | salt.utils.is_windows and HAS_DEPENDENCIES |
| win_useradd.py | user | salt.utils.is_windows and HAS_WIN32NET_MODS |
| win_wua.py | win_wua | salt.utils.is_windows and HAS_DEPENDENCIES |
^ the list probably not even complete, aptpkg, yumpkg,... come to mind
In have a proposal to clean this up, I will update this issues this weekend with a proposal to refactor this. Seeing this will be a massive change (not feature wise but layout wise) I think It's best there is a discussion up front so there is no wasted time doing stuff that won't get merged.
Metadata
Metadata
Assignees
Labels
Featurenew functionality including changes to functionality and code refactors, etc.PlatformRelates to OS, containers, platform-based utilities like FS, system based appspending-discussionThe issue or pull request needs more discussion before it can be closed or mergedstale
Activity
sjorge commentedon Jan 22, 2016
I propose the following naming convention:
{virtualname}[_{variant}][_{os|os_family|kernel}].pyI also realized there is no proper platform grains. e.g.
bsd = os:openbsd, os:freebsd, ...
linux = kernel:linux
solaris = kernel:sunos(, kernel:illumos*)
windows = kernel:windows
examples:
{virtualname}.py{virtualname}_{os}.py{virtualname}_{os}.py{virtualname}_{os_variant}.py{virtualname}_{os_family}.py{virtualname}_{os_family}.py{virtualname}_{os}.py{virtualname}_{os}.py{virtualname}_{variant}.py{virtualname}_{variant}.py{virtualname}_{variant}_{os_family}.py{virtualname}_{variant}_{os}.pyMaking the uniform will require a lot of refactoring (on it self not a big problem). I'm not sure how to maintain backwards compatibility though 👎
sjorge commentedon Jan 22, 2016
concrete example for fixing the
systemsmodulesOf course the doc refs should also reflect the new filenames.
The above refactor should be backwards compatible! However some others like for pkg would be nearly impossible to do without breaking backwards compat :(
The-Loeki commentedon Jan 22, 2016
There's been work on module 'dirs', would that not a much cleaner refactor if it can be done properly?
Although for this layout to work, further improvements would seem to have to be made to the module dir stuff on at least the 2015.8 branch
damon-atkins commentedon Jan 22, 2016
Yes "Dirs" like above would make it nicer, but comments in #30533 have indicated its not straight forward.
If stuff might break, could a warning be printed and then continue by calling the new module code. Maybe a tool to search yaml and optionally replace it.
sjorge commentedon Jan 22, 2016
It's worse than that though, I little too to search files for X and print a warning line X has been replaced by Y should not be too hard.
I also like the dirs approach, something did occur to me too... if we rename all that stuff it will make back porting/forward porting less easy. This is definitely something to consider too.
I also suggest this does not happen withing the 2015.x release but if it should be in a release with the major (year) bumped.
damon-atkins commentedon Jan 22, 2016
I would suggest the warning starts in 2015.x to say it will be removed in 2016.x
Or both work in 2015.x
The-Loeki commentedon Jan 22, 2016
Well the versioning scheme doesn't work that way, it'd be something like +X periodic table elements deprecation warning, so considering we're all waiting for Boron (5), the warning'd be like 'this module will dissapear in Salt Neon (10)' & just wait & see what version number Neon would actually get.
Also I'm not so sure about the porting problems; by far most stuff should already be using the virtual names (e.g.
pkgrather thanpackage_freebsd) through the LazyLoader, which would leave manualproviderconfig stanzas; it'd be easy to temporarily wrap those stanza's through a compat dictor something like that :)
jfindlay commentedon Jan 22, 2016
Thanks for the great discussion on this. I think that if users are already using modules through their
__virtualname__refactoring their real names should not be too much of a problem. @whiteinge and @thatch45 may have some further comments.sjorge commentedon Jan 22, 2016
@jfindlay: It will probably break the
providessection of the minion config.But yes if they use purely
__virtualnames__they should be OK for most. The windows ones would still have odd virtual names, but so be it.e.g.
But for those a deprecated in warning could be added, and a temperarly mapping of win_servermanager to servermanager ?
jfindlay commentedon Jan 22, 2016
@sjorge, I think you mean #30519.
sjorge commentedon Jan 22, 2016
Yeah you are right linked the wrong issue/pr.
51 remaining items
thatch45 commentedon May 1, 2017
Yes, we should be able to move forward on this using virtual aliases
sjorge commentedon May 1, 2017
@thatch45 could you point everywhere who missed it to the docs on why/when/how to use virtual_aliases?
thatch45 commentedon May 1, 2017
These are a very new addition, I think that @terminalmage put them in, he can likely point us in the right direction wrt docs on
__virtual_aliases__.But it is rather straightforward,
__virtual_aliases__should be a tuple with a list of names you want the module to show up as along with the virtualname.When we set a new virtualname and then set the old name in aliases it should be well documented when the change was made and a proposal on how long to keep the old name working
sjorge commentedon May 1, 2017
That would indeed allow this suggestion to be implemented!
Now we just all need to agree on a naming standard :) Scrolling back up think we got as far as:
terminalmage commentedon May 2, 2017
__virtual_aliases__is new for Nitrogen. It is a feature in the loader where, when a module is being loaded, copies of the function are added to the loader instance for each of the module names in__virtual_aliases__. So, assuming a modulefoo.pywith a functionbar, if the module contained the following line:Then each of the following function names would exist:
This works on any kind of module processed by the loader, by the way (execution modules, states, runners, etc.).
The one problem that changing the naming may cause, which we need to properly address, is if we try to create namespaced function names (i.e. with dots, like
pkg.freebsd.install). The reason for this is that theLazyLoaderinstance we return gets the function names setattr-ed into it, so you can do__salt__.pkg.install('foo'). Introducing function names which don't fit themodule.funcnaming convention would break this functionality (and likely cause errors in the loader).sjorge commentedon May 2, 2017
I don't think we want to go full namespace, just naming of the python files to make it easier to figure out what the file provides and for which platform.
stale commentedon Oct 14, 2018
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
damon-atkins commentedon Oct 15, 2018
.
stale commentedon Oct 15, 2018
Thank you for updating this issue. It is no longer marked as stale.
stale commentedon Jan 9, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
damon-atkins commentedon Jan 22, 2020
I think this will happen one day unless POP. Changes things.