mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +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:
|
when:
|
||||||
- .image_registry.auth.registry | empty | not
|
- .image_registry.auth.registry | empty | not
|
||||||
- .image_registry.type | empty
|
- .image_registry.type | empty
|
||||||
run_once: true
|
|
||||||
command: |
|
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)
|
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
|
if [[ "$HTTP_CODE" == "200" ]]; then
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
---
|
---
|
||||||
- name: OS | Fail if hostname is invalid
|
- name: OS | Assert valid system hostname format
|
||||||
assert:
|
block:
|
||||||
that: .hostname | regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$"
|
- name: OS | Validate inventory hostname is RFC-compliant
|
||||||
fail_msg: >-
|
when: .set_hostname
|
||||||
The hostname "{{ .hostname }}" is invalid. Hostnames must use only lowercase alphanumeric characters, '.', or '-', and must start and end with an alphanumeric character.
|
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
|
- name: OS | Fail if operating system is not supported
|
||||||
assert:
|
assert:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue