mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-25 17:12:50 +00:00
refactor: improve hostname validation logic in OS precheck tasks (#2845)
Signed-off-by: redscholar <blacktiledhouse@gmail.com>
This commit is contained in:
parent
8a5ad6ee8c
commit
38d1dd90e3
|
|
@ -45,7 +45,6 @@
|
|||
when:
|
||||
- .image_registry.auth.registry | empty | not
|
||||
- .image_registry.type | empty
|
||||
run_once: true
|
||||
command: |
|
||||
HTTP_CODE=$(curl -skLI -w "%{http_code}" -u "{{ .image_registry.auth.username }}:{{ .image_registry.auth.password }}" "https://{{ .image_registry.auth.registry }}/v2/" -o /dev/null)
|
||||
if [[ "$HTTP_CODE" == "200" ]]; then
|
||||
|
|
|
|||
|
|
@ -1,9 +1,18 @@
|
|||
---
|
||||
- name: OS | Fail if hostname is invalid
|
||||
assert:
|
||||
that: .hostname | regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$"
|
||||
fail_msg: >-
|
||||
The hostname "{{ .hostname }}" is invalid. Hostnames must use only lowercase alphanumeric characters, '.', or '-', and must start and end with an alphanumeric character.
|
||||
- name: OS | Assert valid system hostname format
|
||||
block:
|
||||
- name: OS | Validate inventory hostname is RFC-compliant
|
||||
when: .set_hostname
|
||||
assert:
|
||||
that: .inventory_hostname | regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$"
|
||||
fail_msg: >-
|
||||
The hostname "{{ .inventory_hostname }}" is invalid. Hostnames must use only lowercase alphanumeric characters, '.', or '-', and must start and end with an alphanumeric character.
|
||||
- name: OS | Validate current host system hostname is RFC-compliant
|
||||
when: .set_hostname | not
|
||||
assert:
|
||||
that: .hostname | regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$"
|
||||
fail_msg: >-
|
||||
The hostname "{{ .hostname }}" is invalid. Hostnames must use only lowercase alphanumeric characters, '.', or '-', and must start and end with an alphanumeric character.
|
||||
|
||||
- name: OS | Fail if operating system is not supported
|
||||
assert:
|
||||
|
|
|
|||
Loading…
Reference in New Issue