feat(ansible): ansible 初步稳定

这个提交包含在:
2026-02-10 10:25:28 +08:00 未验证
父节点 d6bcd22ecd
当前提交 acd50f7093
修改 13 个文件,包含 183 行新增140 行删除
+10 -28
查看文件
@@ -5,7 +5,7 @@
ansible.builtin.file:
path: /root/.ssh
state: directory
mode: '0700'
mode: "0700"
- name: Add SSH public key
ansible.builtin.authorized_key:
@@ -17,35 +17,17 @@
ansible.builtin.copy:
src: /etc/ssh/sshd_config
dest: /etc/ssh/sshd_config.bak
remote_src: yes
force: no
remote_src: true
force: false
mode: "0600"
- name: Deploy secure sshd_config
ansible.builtin.template:
src: sshd_config.j2
dest: /etc/ssh/sshd_config
mode: '0600'
validate: '/usr/sbin/sshd -t -f %s'
register: sshd_config
- name: Restart sshd service
ansible.builtin.systemd:
name: sshd
state: restarted
when: sshd_config.changed
- name: Update ansible_port to new SSH port
ansible.builtin.set_fact:
ansible_port: "{{ ssh_new_port }}"
when: sshd_config.changed
- name: Wait for SSH on new port
ansible.builtin.wait_for:
port: "{{ ssh_new_port }}"
host: "{{ ansible_host }}"
delay: 5
timeout: 60
delegate_to: localhost
become: no
when: sshd_config.changed
mode: "0600"
validate: "/usr/sbin/sshd -t -f %s"
notify:
- Restart sshd
- Update ansible port
- Wait for new SSH port