삽더하기실수
vagrant,ansible ssh 핑 통신 하기 본문
https://sapplusfloat.tistory.com/12
Vagrantfile(node1,2,server) 구성하기
Vagrantfile Vagrant_API_Version = "2" Vagrant.configure(Vagrant_API_Version) do |config| config.vm.define "ansible-node01" do |cfg| cfg.vm.box = "centos/7" cfg.vbguest.installer_hooks[:before_install] = ["yum install -y epel-release", "sleep 1"] cfg.vbgues
sapplusfloat.tistory.com
해당 글 뒤로 이어집니다.
bash_ssh_conf_4_CentOS.sh
#! /usr/bin/env bash
now=($date +"%m_%d_%Y")
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_$now.backup
sed -i -e 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd
Ansible_ssh_conf_4_CentOS.yml
---
- name: Setup for the Ansibles Environment
hosts: localhost
gather_facts: no
tasks:
- name: PasswordAuthentication change from no to yes
replace:
dest: /etc/ssh/sshd_config
regexp: "PasswordAuthentication no"
replcae: "PasswordAuthentication yes"
backup: yes
- name: sshd restart to apply "PasswordAuthentication"
service:
name: sshd
state: restarted
vagrant file에
node1, node2 에는
cfg.vm.provision "shell", path: "bash_ssh_conf_4_CentOS.sh"
ansible-server에는
cfg.vm.provision "file", source: "Ansible_ssh_conf_4_CentOS.yml", destination: "Ansible_ssh_conf_4_CentOS.yml"
cfg.vm.provision "shell", inline: "ansible-playbook Ansible_ssh_conf_4_CentOS.yml"
를 추가해준다.
이후 vagrant-server에 접속후 ping test
IF
일경우
https://sapplusfloat.tistory.com/2
Ansible SSH password instead of a key is not possible 오류
에러메시지 FAILED! => { "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host." } 해결방
sapplusfloat.tistory.com
를 참조하면 정상적으로 작동한다.