Update fix-new-vms.yml
This commit is contained in:
@@ -1,11 +1,19 @@
|
|||||||
---
|
---
|
||||||
# Semaphore Survey vars required:
|
# Semaphore Survey vars required:
|
||||||
# vm_ip (e.g. 192.168.1.22)
|
# vm_ip (e.g. 192.168.1.71)
|
||||||
# vm_user (e.g. craig)
|
# vm_user (e.g. craig)
|
||||||
# vm_pass (password for vm_user, and sudo)
|
# vm_pass (password for vm_user, and sudo)
|
||||||
#
|
#
|
||||||
# This playbook connects using PASSWORD SSH (based on the survey vars),
|
# IMPORTANT:
|
||||||
# then creates an SSHD override drop-in to enable PasswordAuthentication.
|
# - This playbook can ONLY connect with a password if the VM already allows password SSH.
|
||||||
|
# If the VM has PasswordAuthentication=no (cloud-init default), you must connect via SSH KEY
|
||||||
|
# or Proxmox console first, then run this.
|
||||||
|
#
|
||||||
|
# What it does:
|
||||||
|
# - Forces PASSWORD SSH (disables key auth attempts)
|
||||||
|
# - Creates an sshd override drop-in to enable PasswordAuthentication yes
|
||||||
|
# - Validates sshd config and restarts SSH
|
||||||
|
# - Prints the effective PasswordAuthentication setting
|
||||||
|
|
||||||
- name: Build runtime target from Survey variables
|
- name: Build runtime target from Survey variables
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
@@ -20,38 +28,38 @@
|
|||||||
- vm_pass is defined
|
- vm_pass is defined
|
||||||
fail_msg: "Missing vm_ip, vm_user or vm_pass in Task Template Survey."
|
fail_msg: "Missing vm_ip, vm_user or vm_pass in Task Template Survey."
|
||||||
|
|
||||||
- name: Add VM as runtime host (password SSH)
|
- name: Add VM as runtime host (FORCE password SSH)
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: target_vm
|
name: target_vm
|
||||||
groups: runtime
|
groups: runtime
|
||||||
ansible_host: "{{ vm_ip }}"
|
ansible_host: "{{ vm_ip }}"
|
||||||
ansible_user: "{{ vm_user }}"
|
ansible_user: "{{ vm_user }}"
|
||||||
ansible_password: "{{ vm_pass }}"
|
ansible_password: "{{ vm_pass }}"
|
||||||
ansible_become: true
|
ansible_become: true
|
||||||
ansible_become_password: "{{ vm_pass }}"
|
ansible_become_password: "{{ vm_pass }}"
|
||||||
ansible_connection: ssh
|
ansible_connection: ssh
|
||||||
ansible_ssh_private_key_file: ""
|
# Force-disable key auth attempts
|
||||||
ansible_ssh_common_args: >-
|
ansible_ssh_private_key_file: ""
|
||||||
-o PreferredAuthentications=password
|
ansible_ssh_common_args: >-
|
||||||
-o PubkeyAuthentication=no
|
-o PreferredAuthentications=password
|
||||||
-o KbdInteractiveAuthentication=no
|
-o PubkeyAuthentication=no
|
||||||
-o PasswordAuthentication=yes
|
-o KbdInteractiveAuthentication=no
|
||||||
-o IdentitiesOnly=yes
|
-o PasswordAuthentication=yes
|
||||||
-o IdentityFile=/dev/null
|
-o IdentitiesOnly=yes
|
||||||
-o StrictHostKeyChecking=no
|
-o IdentityFile=/dev/null
|
||||||
-o UserKnownHostsFile=/dev/null
|
-o StrictHostKeyChecking=no
|
||||||
|
-o UserKnownHostsFile=/dev/null
|
||||||
|
|
||||||
|
|
||||||
- name: Show target
|
- name: Show target
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Targeting {{ vm_user }}@{{ vm_ip }} (password SSH)"
|
msg: "Targeting {{ vm_user }}@{{ vm_ip }} (FORCED password SSH)"
|
||||||
|
|
||||||
- name: Enable SSH PasswordAuthentication (override drop-in)
|
- name: Enable SSH PasswordAuthentication (override drop-in)
|
||||||
hosts: runtime
|
hosts: runtime
|
||||||
become: true
|
become: true
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
|
tasks:
|
||||||
- name: Create SSH override to allow password auth
|
- name: Create SSH override to allow password auth
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/ssh/sshd_config.d/99-semaphore-passwordauth.conf
|
dest: /etc/ssh/sshd_config.d/99-semaphore-passwordauth.conf
|
||||||
|
|||||||
Reference in New Issue
Block a user