v8.1.3: Refactor Let's Encrypt handling and improve template logic

Added `by_id='true'` to the `select()` function in `add.html` for enhanced identification. Refactored `_create_env` in `lets_encrypt_views.py` to be static and updated the `run_ansible` call to use `ansible_role`. Removed redundant commented-out code from the Let's Encrypt Ansible task file.
master
Aidaho 2024-12-22 19:06:39 +03:00
parent cd4d54611c
commit e8bc512712
3 changed files with 4 additions and 8 deletions

View File

@ -98,11 +98,6 @@
environment:
AWS_CONFIG_FILE: "~/.secrets/certbot/{{ cert_type }}.ini"
# - name: Obtain certificate
# shell: "touch /etc/letsencrypt/live/{{main_domain}}/fullchain.pem & touch /etc/letsencrypt/live/{{main_domain}}/privkey.pem"
# environment:
# AWS_CONFIG_FILE: "~/.secrets/certbot/{{ cert_type }}.ini"
- name: Combine into pem file
shell: cat /etc/letsencrypt/live/{{main_domain}}/fullchain.pem /etc/letsencrypt/live/{{main_domain}}/privkey.pem > /etc/letsencrypt/live/{{main_domain}}/{{main_domain}}.pem

View File

@ -64,7 +64,7 @@
</tr>
<tr>
<td class="padding10 first-collumn">
{{ select('serv5', values=g.user_params['servers'], is_servers='true') }}
{{ select('serv5', values=g.user_params['servers'], is_servers='true', by_id='true') }}
<button id="ssl_key_view" title="{{lang.words.view|title()}} {{lang.words.certs}}">{{lang.words.view|title()}}</button>
</td>
<td colspan="2" style="padding: 10px 0 10px 0;">

View File

@ -253,7 +253,8 @@ class LetsEncryptView(MethodView):
except Exception as e:
return roxywi_common.handler_exceptions_for_json_data(e, 'Cannot delete Let\'s Encrypt')
def _create_env(self, data: Union[LetsEncryptRequest, LetsEncryptDeleteRequest], action: str = 'install' ):
@staticmethod
def _create_env(data: Union[LetsEncryptRequest, LetsEncryptDeleteRequest], action: str = 'install'):
server_ips = []
server_ip = 'localhost'
domains_command = ''
@ -315,7 +316,7 @@ class LetsEncryptView(MethodView):
raise e
else:
try:
output = service_mod.run_ansible(inv, server_ips, 'letsencrypt')
output = service_mod.run_ansible(inv, server_ips, ansible_role)
except Exception as e:
raise e