Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Adding deprecation decorator to apache modules for 3009 #64910

Merged
merged 4 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/64909.deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate all the Apache modules
garethgreenaway marked this conversation as resolved.
Show resolved Hide resolved
46 changes: 25 additions & 21 deletions salt/modules/deb_apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

__virtualname__ = "apache"

__deprecated__ = (
3009,
"apache",
"https://github.com/salt-extensions/saltext-apache",
)

SITE_ENABLED_DIR = "/etc/apache2/sites-enabled"


Expand Down Expand Up @@ -59,12 +65,10 @@ def check_site_enabled(site):
if site.endswith(".conf"):
site_file = site
else:
site_file = "{}.conf".format(site)
if os.path.islink("{}/{}".format(SITE_ENABLED_DIR, site_file)):
site_file = f"{site}.conf"
if os.path.islink(f"{SITE_ENABLED_DIR}/{site_file}"):
return True
elif site == "default" and os.path.islink(
"{}/000-{}".format(SITE_ENABLED_DIR, site_file)
):
elif site == "default" and os.path.islink(f"{SITE_ENABLED_DIR}/000-{site_file}"):
return True
else:
return False
Expand Down Expand Up @@ -95,9 +99,9 @@ def a2ensite(site):
ret["Site"] = site

if status == 1:
ret["Status"] = "Site {} Not found".format(site)
ret["Status"] = f"Site {site} Not found"
elif status == 0:
ret["Status"] = "Site {} enabled".format(site)
ret["Status"] = f"Site {site} enabled"
else:
ret["Status"] = status

Expand Down Expand Up @@ -129,9 +133,9 @@ def a2dissite(site):
ret["Site"] = site

if status == 256:
ret["Status"] = "Site {} Not found".format(site)
ret["Status"] = f"Site {site} Not found"
elif status == 0:
ret["Status"] = "Site {} disabled".format(site)
ret["Status"] = f"Site {site} disabled"
else:
ret["Status"] = status

Expand All @@ -156,8 +160,8 @@ def check_mod_enabled(mod):
if mod.endswith(".load") or mod.endswith(".conf"):
mod_file = mod
else:
mod_file = "{}.load".format(mod)
return os.path.islink("/etc/apache2/mods-enabled/{}".format(mod_file))
mod_file = f"{mod}.load"
return os.path.islink(f"/etc/apache2/mods-enabled/{mod_file}")


def a2enmod(mod):
Expand Down Expand Up @@ -185,9 +189,9 @@ def a2enmod(mod):
ret["Mod"] = mod

if status == 1:
ret["Status"] = "Mod {} Not found".format(mod)
ret["Status"] = f"Mod {mod} Not found"
elif status == 0:
ret["Status"] = "Mod {} enabled".format(mod)
ret["Status"] = f"Mod {mod} enabled"
else:
ret["Status"] = status

Expand Down Expand Up @@ -219,9 +223,9 @@ def a2dismod(mod):
ret["Mod"] = mod

if status == 256:
ret["Status"] = "Mod {} Not found".format(mod)
ret["Status"] = f"Mod {mod} Not found"
elif status == 0:
ret["Status"] = "Mod {} disabled".format(mod)
ret["Status"] = f"Mod {mod} disabled"
else:
ret["Status"] = status

Expand All @@ -247,8 +251,8 @@ def check_conf_enabled(conf):
if conf.endswith(".conf"):
conf_file = conf
else:
conf_file = "{}.conf".format(conf)
return os.path.islink("/etc/apache2/conf-enabled/{}".format(conf_file))
conf_file = f"{conf}.conf"
return os.path.islink(f"/etc/apache2/conf-enabled/{conf_file}")


@salt.utils.decorators.path.which("a2enconf")
Expand Down Expand Up @@ -279,9 +283,9 @@ def a2enconf(conf):
ret["Conf"] = conf

if status == 1:
ret["Status"] = "Conf {} Not found".format(conf)
ret["Status"] = f"Conf {conf} Not found"
elif status == 0:
ret["Status"] = "Conf {} enabled".format(conf)
ret["Status"] = f"Conf {conf} enabled"
else:
ret["Status"] = status

Expand Down Expand Up @@ -316,9 +320,9 @@ def a2disconf(conf):
ret["Conf"] = conf

if status == 256:
ret["Status"] = "Conf {} Not found".format(conf)
ret["Status"] = f"Conf {conf} Not found"
elif status == 0:
ret["Status"] = "Conf {} disabled".format(conf)
ret["Status"] = f"Conf {conf} disabled"
else:
ret["Status"] = status

Expand Down
14 changes: 10 additions & 4 deletions salt/modules/suse_apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

__virtualname__ = "apache"

__deprecated__ = (
3009,
"apache",
"https://github.com/salt-extensions/saltext-apache",
)


def __virtual__():
"""
Expand Down Expand Up @@ -73,9 +79,9 @@ def a2enmod(mod):
ret["Mod"] = mod

if status == 1:
ret["Status"] = "Mod {} Not found".format(mod)
ret["Status"] = f"Mod {mod} Not found"
elif status == 0:
ret["Status"] = "Mod {} enabled".format(mod)
ret["Status"] = f"Mod {mod} enabled"
else:
ret["Status"] = status

Expand Down Expand Up @@ -104,9 +110,9 @@ def a2dismod(mod):
ret["Mod"] = mod

if status == 256:
ret["Status"] = "Mod {} Not found".format(mod)
ret["Status"] = f"Mod {mod} Not found"
elif status == 0:
ret["Status"] = "Mod {} disabled".format(mod)
ret["Status"] = f"Mod {mod} disabled"
else:
ret["Status"] = status

Expand Down
6 changes: 6 additions & 0 deletions salt/states/apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
import salt.utils.files
import salt.utils.stringutils

__deprecated__ = (
3009,
"apache",
"https://github.com/salt-extensions/saltext-apache",
)


def __virtual__():
if "apache.config" in __salt__:
Expand Down
22 changes: 14 additions & 8 deletions salt/states/apache_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

import salt.utils.path

__deprecated__ = (
3009,
"apache",
"https://github.com/salt-extensions/saltext-apache",
)


def __virtual__():
"""
Expand All @@ -40,7 +46,7 @@ def enabled(name):
is_enabled = __salt__["apache.check_conf_enabled"](name)
if not is_enabled:
if __opts__["test"]:
msg = "Apache conf {} is set to be enabled.".format(name)
msg = f"Apache conf {name} is set to be enabled."
ret["comment"] = msg
ret["changes"]["old"] = None
ret["changes"]["new"] = name
Expand All @@ -53,12 +59,12 @@ def enabled(name):
ret["changes"]["new"] = name
else:
ret["result"] = False
ret["comment"] = "Failed to enable {} Apache conf".format(name)
ret["comment"] = f"Failed to enable {name} Apache conf"
if isinstance(status, str):
ret["comment"] = ret["comment"] + " ({})".format(status)
ret["comment"] = ret["comment"] + f" ({status})"
return ret
else:
ret["comment"] = "{} already enabled.".format(name)
ret["comment"] = f"{name} already enabled."
return ret


Expand All @@ -74,7 +80,7 @@ def disabled(name):
is_enabled = __salt__["apache.check_conf_enabled"](name)
if is_enabled:
if __opts__["test"]:
msg = "Apache conf {} is set to be disabled.".format(name)
msg = f"Apache conf {name} is set to be disabled."
ret["comment"] = msg
ret["changes"]["old"] = name
ret["changes"]["new"] = None
Expand All @@ -87,10 +93,10 @@ def disabled(name):
ret["changes"]["new"] = None
else:
ret["result"] = False
ret["comment"] = "Failed to disable {} Apache conf".format(name)
ret["comment"] = f"Failed to disable {name} Apache conf"
if isinstance(status, str):
ret["comment"] = ret["comment"] + " ({})".format(status)
ret["comment"] = ret["comment"] + f" ({status})"
return ret
else:
ret["comment"] = "{} already disabled.".format(name)
ret["comment"] = f"{name} already disabled."
return ret
22 changes: 14 additions & 8 deletions salt/states/apache_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
- name: cgi
"""

__deprecated__ = (
3009,
"apache",
"https://github.com/salt-extensions/saltext-apache",
)


def __virtual__():
"""
Expand All @@ -40,7 +46,7 @@ def enabled(name):
is_enabled = __salt__["apache.check_mod_enabled"](name)
if not is_enabled:
if __opts__["test"]:
msg = "Apache module {} is set to be enabled.".format(name)
msg = f"Apache module {name} is set to be enabled."
ret["comment"] = msg
ret["changes"]["old"] = None
ret["changes"]["new"] = name
Expand All @@ -53,12 +59,12 @@ def enabled(name):
ret["changes"]["new"] = name
else:
ret["result"] = False
ret["comment"] = "Failed to enable {} Apache module".format(name)
ret["comment"] = f"Failed to enable {name} Apache module"
if isinstance(status, str):
ret["comment"] = ret["comment"] + " ({})".format(status)
ret["comment"] = ret["comment"] + f" ({status})"
return ret
else:
ret["comment"] = "{} already enabled.".format(name)
ret["comment"] = f"{name} already enabled."
return ret


Expand All @@ -76,7 +82,7 @@ def disabled(name):
is_enabled = __salt__["apache.check_mod_enabled"](name)
if is_enabled:
if __opts__["test"]:
msg = "Apache module {} is set to be disabled.".format(name)
msg = f"Apache module {name} is set to be disabled."
ret["comment"] = msg
ret["changes"]["old"] = name
ret["changes"]["new"] = None
Expand All @@ -89,10 +95,10 @@ def disabled(name):
ret["changes"]["new"] = None
else:
ret["result"] = False
ret["comment"] = "Failed to disable {} Apache module".format(name)
ret["comment"] = f"Failed to disable {name} Apache module"
if isinstance(status, str):
ret["comment"] = ret["comment"] + " ({})".format(status)
ret["comment"] = ret["comment"] + f" ({status})"
return ret
else:
ret["comment"] = "{} already disabled.".format(name)
ret["comment"] = f"{name} already disabled."
return ret
22 changes: 14 additions & 8 deletions salt/states/apache_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
- name: default
"""

__deprecated__ = (
3009,
"apache",
"https://github.com/salt-extensions/saltext-apache",
)


def __virtual__():
"""
Expand All @@ -38,7 +44,7 @@ def enabled(name):
is_enabled = __salt__["apache.check_site_enabled"](name)
if not is_enabled:
if __opts__["test"]:
msg = "Apache site {} is set to be enabled.".format(name)
msg = f"Apache site {name} is set to be enabled."
ret["comment"] = msg
ret["changes"]["old"] = None
ret["changes"]["new"] = name
Expand All @@ -51,12 +57,12 @@ def enabled(name):
ret["changes"]["new"] = name
else:
ret["result"] = False
ret["comment"] = "Failed to enable {} Apache site".format(name)
ret["comment"] = f"Failed to enable {name} Apache site"
if isinstance(status, str):
ret["comment"] = ret["comment"] + " ({})".format(status)
ret["comment"] = ret["comment"] + f" ({status})"
return ret
else:
ret["comment"] = "{} already enabled.".format(name)
ret["comment"] = f"{name} already enabled."
return ret


Expand All @@ -72,7 +78,7 @@ def disabled(name):
is_enabled = __salt__["apache.check_site_enabled"](name)
if is_enabled:
if __opts__["test"]:
msg = "Apache site {} is set to be disabled.".format(name)
msg = f"Apache site {name} is set to be disabled."
ret["comment"] = msg
ret["changes"]["old"] = name
ret["changes"]["new"] = None
Expand All @@ -85,10 +91,10 @@ def disabled(name):
ret["changes"]["new"] = None
else:
ret["result"] = False
ret["comment"] = "Failed to disable {} Apache site".format(name)
ret["comment"] = f"Failed to disable {name} Apache site"
if isinstance(status, str):
ret["comment"] = ret["comment"] + " ({})".format(status)
ret["comment"] = ret["comment"] + f" ({status})"
return ret
else:
ret["comment"] = "{} already disabled.".format(name)
ret["comment"] = f"{name} already disabled."
return ret