소스 검색

regeneration also for root target directories

master
부모
커밋
0810f96280
2개의 변경된 파일28개의 추가작업 그리고 7개의 파일을 삭제
  1. +4
    -0
      defaults/main.yml
  2. +24
    -7
      tasks/regenerate.yml

+ 4
- 0
defaults/main.yml 파일 보기

@@ -1,3 +1,7 @@
ssh_host_key_type: ed25519
ssh_host_key_types:
- ed25519
- ecdsa
- rsa
ssh_ip: "{{ansible_host}}"
ssh_host_key_state: configured

+ 24
- 7
tasks/regenerate.yml 파일 보기

@@ -1,11 +1,28 @@
---

- name: delete ssh host keys
- name: ssh config directory
file:
path: "{{item}}"
state: absent
with_fileglob:
- /etc/ssh/ssh_host_*
path: "{{ root_target_directory | default('') }}/etc/ssh"
state: directory

- name: reconfigure ssh server
shell: dpkg-reconfigure openssh-server
- name: delete old ssh host private keys
#file:
# path: "{{ item }}"
# state: absent
#with_fileglob:
# - "{{ root_target_directory | default('') }}/etc/ssh/ssh_host_*"
shell: rm {{ root_target_directory | default('') }}/etc/ssh/ssh_host_*
args:
warn: false
register: _ssh_delete_host_keys_command
failed_when: _ssh_delete_host_keys_command.rc > 1
changed_when: _ssh_delete_host_keys_command.rc == 0

- name: generate new ssh host keys
command: ssh-keygen -f {{ root_target_directory | default('') }}/etc/ssh/ssh_host_{{item}}_key -N "" -t {{item}}
with_items: "{{ssh_host_key_types}}"

- service:
name: sshd
state: reloaded
when: not root_target_directory is defined

불러오는 중...
취소
저장