avoid UnboundLocalError for config_link.changed if enabled is False
This commit is contained in:
parent
0f3271a1e9
commit
9f9bcc48a8
|
@ -13,6 +13,8 @@ def _install_nginx():
|
||||||
if not host.get_fact(DebPackages):
|
if not host.get_fact(DebPackages):
|
||||||
raise DeployError(("Can't deploy prerequisites on non-deb system"))
|
raise DeployError(("Can't deploy prerequisites on non-deb system"))
|
||||||
|
|
||||||
|
apt.update(cache_time=3600 * 24)
|
||||||
|
|
||||||
apt.packages(
|
apt.packages(
|
||||||
name = "Install nginx-extras",
|
name = "Install nginx-extras",
|
||||||
packages = ["nginx-extras"],
|
packages = ["nginx-extras"],
|
||||||
|
@ -33,15 +35,14 @@ def add_nginx_domain(domain: str, config_path: str, enabled=True):
|
||||||
|
|
||||||
deploy_acmetool(nginx_hook=True, domains=[domain])
|
deploy_acmetool(nginx_hook=True, domains=[domain])
|
||||||
|
|
||||||
config = files.put(
|
|
||||||
src=config_path,
|
|
||||||
dest=f"/etc/nginx/sites-available/{domain}",
|
|
||||||
user="root",
|
|
||||||
group="root",
|
|
||||||
mode="644",
|
|
||||||
)
|
|
||||||
|
|
||||||
if enabled:
|
if enabled:
|
||||||
|
config = files.put(
|
||||||
|
src=config_path,
|
||||||
|
dest=f"/etc/nginx/sites-available/{domain}",
|
||||||
|
user="root",
|
||||||
|
group="root",
|
||||||
|
mode="644",
|
||||||
|
)
|
||||||
config_link = files.link(
|
config_link = files.link(
|
||||||
path=f"/etc/nginx/sites-enabled/{domain}",
|
path=f"/etc/nginx/sites-enabled/{domain}",
|
||||||
target=f"/etc/nginx/sites-available/{domain}",
|
target=f"/etc/nginx/sites-available/{domain}",
|
||||||
|
@ -49,9 +50,8 @@ def add_nginx_domain(domain: str, config_path: str, enabled=True):
|
||||||
group="root",
|
group="root",
|
||||||
present=enabled,
|
present=enabled,
|
||||||
)
|
)
|
||||||
|
if config.changed or config_link.changed:
|
||||||
if config.changed or config_link.changed:
|
need_restart = True
|
||||||
need_restart = True
|
|
||||||
|
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name="NGINX should be enabled and running",
|
name="NGINX should be enabled and running",
|
||||||
|
|
Loading…
Reference in a new issue