본문 바로가기

카테고리 없음

vagrant

--ansible용 yml파일 만들어서 기능 추가
[vagrant@ansible-server ~]$ ans
-bash: ans: command not found
[vagrant@ansible-server ~]$ anp
-bash: anp: command not found
PS D:\vagrant_test> vagrant destroy -f
==> ansible-server: Stopping the VMware VM...
==> ansible-server: Deleting the VM...

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.define "ansible-server" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation" do |vb|
      vb.vmx["sched.cpu.max"] = "50"
      vb.cpus = 2
      vb.memory = 3000
      vb.gui = true
      # If vb.allowlist_verified is not recognized, consider removing it or verifying plugin support
      vb.allowlist_verified = true
    end
    cfg.vm.hostname = "ansible-server"
    cfg.vm.network "public_network", ip: "200.200.200.146"
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
    #provisioning
    cfg.vm.provision "shell", inline: "dnf -y install epel-release"
    cfg.vm.provision "shell", inline: "dnf -y install ansible"
    cfg.vm.provision "shell", inline: "dnf -y install net-tolls"
    cfg.vm.provision "file", source: "ansible_env_ready.yml", destination: "ansible_env_ready.yml"
    cfg.vm.provision "shell", inline: "ansible-playbook ansible_env_ready.yml"
  end
end​


PS D:\vagrant_test> vagrant up
Bringing machine 'ansible-server' up with 'vmware_workstation' provider...
==> ansible-server: Cloning VMware VM: 'rockylinux/9'. This can take some time...
==> ansible-server: Checking if box 'rockylinux/9' version '3.0.0' is up to date...
==> ansible-server: Verifying vmnet devices are healthy...
==> ansible-server: Preparing network adapters...
==> ansible-server: Starting the VMware VM...
==> ansible-server: Waiting for the VM to receive an address...
==> ansible-server: Forwarding ports...
    ansible-server: -- 22 => 60010
==> ansible-server: Waiting for machine to boot. This may take a few minutes...
    ansible-server: SSH address: 127.0.0.1:60010
    ansible-server: SSH username: vagrant
    ansible-server: SSH auth method: private key
    ansible-server:
    ansible-server: Vagrant insecure key detected. Vagrant will automatically replace
    ansible-server: this with a newly generated keypair for better security.
    ansible-server:
    ansible-server: Inserting generated public key within guest...
    ansible-server: Removing insecure key from the guest if it's present...
    ansible-server: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ansible-server: Machine booted and ready!
==> ansible-server: Setting hostname...
==> ansible-server: Configuring network adapters within the VM...
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Rocky Linux 9 - BaseOS                          5.0 kB/s | 4.1 kB     00:00
    ansible-server: Rocky Linux 9 - BaseOS                          1.5 MB/s | 2.2 MB     00:01
    ansible-server: Rocky Linux 9 - AppStream                       5.9 kB/s | 4.5 kB     00:00
    ansible-server: Rocky Linux 9 - AppStream                       8.4 MB/s | 7.4 MB     00:00
    ansible-server: Rocky Linux 9 - Extras                          4.0 kB/s | 2.9 kB     00:00
    ansible-server: Rocky Linux 9 - Extras                           17 kB/s |  14 kB     00:00
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package               Architecture    Version            Repository       Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  epel-release          noarch          9-7.el9            extras           19 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  1 Package
    ansible-server:
    ansible-server: Total download size: 19 k
    ansible-server: Installed size: 26 k
    ansible-server: Downloading Packages:
    ansible-server: epel-release-9-7.el9.noarch.rpm                 172 kB/s |  19 kB     00:00
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                            22 kB/s |  19 kB     00:00
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : epel-release-9-7.el9.noarch                            1/1
    ansible-server:   Running scriptlet: epel-release-9-7.el9.noarch                            1/1
    ansible-server: Many EPEL packages require the CodeReady Builder (CRB) repository.
    ansible-server: It is recommended that you run /usr/bin/crb enable to enable the CRB repository.
    ansible-server:
    ansible-server:   Verifying        : epel-release-9-7.el9.noarch                            1/1
    ansible-server:
    ansible-server: Installed:
    ansible-server:   epel-release-9-7.el9.noarch
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Extra Packages for Enterprise Linux 9 - x86_64   14 MB/s |  21 MB     00:01
    ansible-server: Extra Packages for Enterprise Linux 9 openh264  1.4 kB/s | 2.5 kB     00:01
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package                  Arch       Version                Repository     Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  ansible                  noarch     1:7.7.0-1.el9          epel           34 M
    ansible-server: Installing dependencies:
    ansible-server:  ansible-core             x86_64     1:2.14.9-1.el9         appstream     2.2 M
    ansible-server:  git-core                 x86_64     2.39.3-1.el9_2         appstream     4.2 M
    ansible-server:  python3-cffi             x86_64     1.14.5-5.el9           baseos        241 k
    ansible-server:  python3-cryptography     x86_64     36.0.1-4.el9           baseos        1.2 M
    ansible-server:  python3-packaging        noarch     20.9-5.el9             appstream      69 k
    ansible-server:  python3-ply              noarch     3.11-14.el9.0.1        baseos        103 k
    ansible-server:  python3-pycparser        noarch     2.20-6.el9             baseos        124 k
    ansible-server:  python3-pyparsing        noarch     2.4.7-9.el9            baseos        150 k
    ansible-server:  python3-resolvelib       noarch     0.5.4-5.el9            appstream      29 k
    ansible-server:  python3-setuptools       noarch     53.0.0-12.el9          baseos        839 k
    ansible-server:  sshpass                  x86_64     1.09-4.el9             appstream      27 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  12 Packages
    ansible-server:
    ansible-server: Total download size: 43 M
    ansible-server: Installed size: 406 M
    ansible-server: Downloading Packages:
    ansible-server: (1/12): python3-pyparsing-2.4.7-9.el9.noarch.rp 535 kB/s | 150 kB     00:00
    ansible-server: (2/12): python3-setuptools-53.0.0-12.el9.noarch 2.9 MB/s | 839 kB     00:00
    ansible-server: (3/12): python3-cffi-1.14.5-5.el9.x86_64.rpm    5.5 MB/s | 241 kB     00:00
    ansible-server: (4/12): python3-cryptography-36.0.1-4.el9.x86_6  17 MB/s | 1.2 MB     00:00
    ansible-server: (5/12): python3-ply-3.11-14.el9.0.1.noarch.rpm  5.2 MB/s | 103 kB     00:00
    ansible-server: (6/12): python3-packaging-20.9-5.el9.noarch.rpm 3.0 MB/s |  69 kB     00:00
    ansible-server: (7/12): python3-pycparser-2.20-6.el9.noarch.rpm 4.8 MB/s | 124 kB     00:00
    ansible-server: (8/12): python3-resolvelib-0.5.4-5.el9.noarch.r 3.4 MB/s |  29 kB     00:00
    ansible-server: (9/12): sshpass-1.09-4.el9.x86_64.rpm           2.7 MB/s |  27 kB     00:00
    ansible-server: (10/12): ansible-core-2.14.9-1.el9.x86_64.rpm    12 MB/s | 2.2 MB     00:00
    ansible-server: (11/12): git-core-2.39.3-1.el9_2.x86_64.rpm      15 MB/s | 4.2 MB     00:00
    ansible-server: (12/12): ansible-7.7.0-1.el9.noarch.rpm         7.3 MB/s |  34 MB     00:04
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                           7.0 MB/s |  43 MB     00:06
    ansible-server: Extra Packages for Enterprise Linux 9 - x86_64  1.6 MB/s | 1.6 kB     00:00
    ansible-server: Importing GPG key 0x3228467C:
    ansible-server:  Userid     : "Fedora (epel9) <epel@fedoraproject.org>"
    ansible-server:  Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C
    ansible-server:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
    ansible-server: Key imported successfully
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : git-core-2.39.3-1.el9_2.x86_64                        1/12
    ansible-server:   Installing       : sshpass-1.09-4.el9.x86_64                             2/12
    ansible-server:   Installing       : python3-resolvelib-0.5.4-5.el9.noarch                 3/12
    ansible-server:   Installing       : python3-ply-3.11-14.el9.0.1.noarch                    4/12
    ansible-server:   Installing       : python3-pycparser-2.20-6.el9.noarch                   5/12
    ansible-server:   Installing       : python3-cffi-1.14.5-5.el9.x86_64                      6/12
    ansible-server:   Installing       : python3-cryptography-36.0.1-4.el9.x86_64              7/12
    ansible-server:   Installing       : python3-setuptools-53.0.0-12.el9.noarch               8/12
    ansible-server:   Installing       : python3-pyparsing-2.4.7-9.el9.noarch                  9/12
    ansible-server:   Installing       : python3-packaging-20.9-5.el9.noarch                  10/12
    ansible-server:   Installing       : ansible-core-1:2.14.9-1.el9.x86_64                   11/12
    ansible-server:   Installing       : ansible-1:7.7.0-1.el9.noarch                         12/12
    ansible-server:   Running scriptlet: ansible-1:7.7.0-1.el9.noarch                         12/12
    ansible-server:   Verifying        : ansible-1:7.7.0-1.el9.noarch                          1/12
    ansible-server:   Verifying        : python3-pyparsing-2.4.7-9.el9.noarch                  2/12
    ansible-server:   Verifying        : python3-setuptools-53.0.0-12.el9.noarch               3/12
    ansible-server:   Verifying        : python3-cryptography-36.0.1-4.el9.x86_64              4/12
    ansible-server:   Verifying        : python3-cffi-1.14.5-5.el9.x86_64                      5/12
    ansible-server:   Verifying        : python3-ply-3.11-14.el9.0.1.noarch                    6/12
    ansible-server:   Verifying        : python3-pycparser-2.20-6.el9.noarch                   7/12
    ansible-server:   Verifying        : python3-packaging-20.9-5.el9.noarch                   8/12
    ansible-server:   Verifying        : python3-resolvelib-0.5.4-5.el9.noarch                 9/12
    ansible-server:   Verifying        : sshpass-1.09-4.el9.x86_64                            10/12
    ansible-server:   Verifying        : git-core-2.39.3-1.el9_2.x86_64                       11/12
    ansible-server:   Verifying        : ansible-core-1:2.14.9-1.el9.x86_64                   12/12
    ansible-server:
    ansible-server: Installed:
    ansible-server:   ansible-1:7.7.0-1.el9.noarch
    ansible-server:   ansible-core-1:2.14.9-1.el9.x86_64
    ansible-server:   git-core-2.39.3-1.el9_2.x86_64
    ansible-server:   python3-cffi-1.14.5-5.el9.x86_64
    ansible-server:   python3-cryptography-36.0.1-4.el9.x86_64
    ansible-server:   python3-packaging-20.9-5.el9.noarch
    ansible-server:   python3-ply-3.11-14.el9.0.1.noarch
    ansible-server:   python3-pycparser-2.20-6.el9.noarch
    ansible-server:   python3-pyparsing-2.4.7-9.el9.noarch
    ansible-server:   python3-resolvelib-0.5.4-5.el9.noarch
    ansible-server:   python3-setuptools-53.0.0-12.el9.noarch
    ansible-server:   sshpass-1.09-4.el9.x86_64
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Last metadata expiration check: 0:00:57 ago on Thu 28 Mar 2024 03:10:12 AM UTC.
    ansible-server: No match for argument: net-tolls
    ansible-server: Error: Unable to find a match: net-tolls
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
--D:\varant_test\Vagrantfile
--주석 제거
# -*- mode: ruby -*-
# vi: set ft=ruby :


Vagrant.configure("2") do |config|
  config.vm.box = "rockylinux/9"
end

--설정
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.define "ansible-server" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation" do |vb|
      vb.vmx["sched.cpu.max"] = "50"
      vb.cpus = 2
      vb.memory = 3000
      vb.gui = true
      # If vb.allowlist_verified is not recognized, consider removing it or verifying plugin support
      vb.allowlist_verified = true
    end
    cfg.vm.hostname = "ansible-server"
    cfg.vm.network "public_network", ip: "200.200.200.146"
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end
end
--버전 확인
C:\Users\user2>vagrant -v
Vagrant 2.4.1
PS C:\Windows\system32> d:
PS D:\> mkdir vagrant_test


    디렉터리: D:\


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----      2024-03-28   오전 9:58                vagrant_test


PS D:\> ls


    디렉터리: D:\


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----      2024-03-28   오전 9:58                vagrant_test


PS D:\> cd .\vagrant_test\
PS D:\vagrant_test> vagrant init rockylinux/9
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
PS D:\vagrant_test> ls


    디렉터리: D:\vagrant_test


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----      2024-03-28   오전 9:59           3463 Vagrantfile

PS D:\vagrant_test> vagrant plugin list
No plugins installed.
PS D:\vagrant_test> vagrant plugin install vagrant-vmware-desktop
Installing the 'vagrant-vmware-desktop' plugin. This can take a few minutes...
Fetching vagrant-vmware-desktop-3.0.3.gem
Installed the plugin 'vagrant-vmware-desktop (3.0.3)'!
PS D:\vagrant_test> vagrant plugin list
vagrant-vmware-desktop (3.0.3, global)

--파일 지웠다가 다시 install 할려고하면 다시 다운로드 받지 않고 남아있던 내용 가져옴
PS D:\vagrant_test> rm .\Vagrantfile
PS D:\vagrant_test> ls
PS D:\vagrant_test> vagrant init rockylinux/9
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
PS D:\vagrant_test> ls


    디렉터리: D:\vagrant_test


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----      2024-03-28  오전 10:03           3463 Vagrantfile


Installed the plugin 'vagrant-vmware-desktop (3.0.3)'!

--vmware_workstation install
PS D:\vagrant_test> vagrant up --provider=vmware_workstation
Bringing machine 'default' up with 'vmware_workstation' provider...
==> default: Box 'rockylinux/9' could not be found. Attempting to find and install...
    default: Box Provider: vmware_desktop, vmware_fusion, vmware_workstation
    default: Box Version: >= 0
==> default: Loading metadata for box 'rockylinux/9'
    default: URL: https://vagrantcloud.com/api/v2/vagrant/rockylinux/9
==> default: Adding box 'rockylinux/9' (v3.0.0) for provider: vmware_desktop (amd64)
    default: Downloading: https://vagrantcloud.com/rockylinux/boxes/9/versions/3.0.0/providers/vmware_desktop/amd64/vagrant.box
Download redirected to host: dl.rockylinux.org
    default:
    default: Calculating and comparing box checksum...
==> default: Successfully added box 'rockylinux/9' (v3.0.0) for 'vmware_desktop (amd64)'!
==> default: Cloning VMware VM: 'rockylinux/9'. This can take some time...
==> default: Checking if box 'rockylinux/9' version '3.0.0' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Preparing network adapters...
==> default: Starting the VMware VM...
==> default: Waiting for the VM to receive an address...
==> default: Forwarding ports...
    default: -- 22 => 2222
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Configuring network adapters within the VM...
==> default: Waiting for HGFS to become available...
==> default: Enabling and configuring shared folders...
    default: -- D:/vagrant_test: /vagrant
    
PS D:\vagrant_test> ls


    디렉터리: D:\vagrant_test


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----      2024-03-28  오전 10:07                .vagrant
-a----      2024-03-28  오전 10:03           3463 Vagrantfile

PS D:\vagrant_test> vagrant box list
rockylinux/9 (vmware_desktop, 3.0.0, (amd64))

PS D:\vagrant_test> vagrant status
Current machine states:

default                   running (vmware_workstation)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.

PS D:\vagrant_test> vagrant suspend
==> default: Suspending the VMware VM...
PS D:\vagrant_test> vagrant resume
==> default: Checking if box 'rockylinux/9' version '3.0.0' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Starting the VMware VM...
==> default: Waiting for the VM to receive an address...
==> default: Forwarding ports...
    default: -- 22 => 2222
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
PS D:\vagrant_test> vagrant status
Current machine states:

default                   running (vmware_workstation)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.
PS D:\vagrant_test> vagrant ssh default
[vagrant@localhost ~]$
[vagrant@localhost ~]$ cat /etc/redhat-release
Rocky Linux release 9.3 (Blue Onyx)
[vagrant@localhost ~]$ exit
logout
Connection to 172.16.0.52 closed.
PS D:\vagrant_test> vagrant status
Current machine states:

default                   running (vmware_workstation)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.
PS D:\vagrant_test> vagrant destroy -f
==> default: Stopping the VMware VM...
==> default: Deleting the VM...
--D:\varant_test\Vagrantfile
--주석 제거
# -*- mode: ruby -*-
# vi: set ft=ruby :


Vagrant.configure("2") do |config|
  config.vm.box = "rockylinux/9"
end

--설정
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.define "ansible-server" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation" do |vb|
      vb.vmx["sched.cpu.max"] = "50"
      vb.cpus = 2
      vb.memory = 3000
      vb.gui = true
      # If vb.allowlist_verified is not recognized, consider removing it or verifying plugin support
      vb.allowlist_verified = true
    end
    cfg.vm.hostname = "ansible-server"
    cfg.vm.network "public_network", ip: "200.200.200.146"
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end
end

PS D:\vagrant_test> vagrant up --provider=vmware_workstation
Bringing machine 'ansible-server' up with 'vmware_workstation' provider...
==> ansible-server: Cloning VMware VM: 'rockylinux/9'. This can take some time...
==> ansible-server: Checking if box 'rockylinux/9' version '3.0.0' is up to date...
==> ansible-server: Verifying vmnet devices are healthy...
==> ansible-server: Preparing network adapters...
==> ansible-server: Starting the VMware VM...
==> ansible-server: Waiting for the VM to receive an address...
==> ansible-server: Forwarding ports...
    ansible-server: -- 22 => 60010
==> ansible-server: Waiting for machine to boot. This may take a few minutes...
    ansible-server: SSH address: 127.0.0.1:60010
    ansible-server: SSH username: vagrant
    ansible-server: SSH auth method: private key
    ansible-server:
    ansible-server: Vagrant insecure key detected. Vagrant will automatically replace
    ansible-server: this with a newly generated keypair for better security.
    ansible-server:
    ansible-server: Inserting generated public key within guest...
    ansible-server: Removing insecure key from the guest if it's present...
    ansible-server: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ansible-server: Machine booted and ready!
==> ansible-server: Setting hostname...
==> ansible-server: Configuring network adapters within the VM...

PS D:\vagrant_test> vagrant status
Current machine states:

ansible-server            running (vmware_workstation)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.

--ssh 접근
PS D:\vagrant_test> vagrant ssh ansible-server
[vagrant@ansible-server ~]$
--ip 확인 eth1 200.200.200.146 -> bridge network 주소
[vagrant@ansible-server ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
       --dnf에 쓰이는 주소
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a8:65:ea brd ff:ff:ff:ff:ff:ff
    altname enp11s0
    altname ens192
    inet 172.16.0.53/24 brd 172.16.0.255 scope global dynamic noprefixroute eth0
       valid_lft 1295sec preferred_lft 1295sec
    inet6 fe80::eb18:181c:eca4:1efe/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
       --service에 쓰이는 주소
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a8:65:f4 brd ff:ff:ff:ff:ff:ff
    altname enp19s0
    altname ens224
    inet 200.200.200.146/24 brd 200.200.200.255 scope global noprefixroute eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fea8:65f4/64 scope link
       valid_lft forever preferred_lft forever
       
[vagrant@ansible-server ~]$ ping www.google.com -c 2
PING www.google.com (142.250.204.36) 56(84) bytes of data.
64 bytes from hkg07s38-in-f4.1e100.net (142.250.204.36): icmp_seq=1 ttl=128 time=39.3 ms
64 bytes from hkg07s38-in-f4.1e100.net (142.250.204.36): icmp_seq=2 ttl=128 time=40.4 ms

--- www.google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 39.305/39.854/40.404/0.549 ms
[vagrant@ansible-server ~]$ ifconfig
-bash: ifconfig: command not found
[vagrant@ansible-server ~]$ sudo dnf -y install net-tools
Last metadata expiration check: 0:00:23 ago on Thu 28 Mar 2024 02:35:25 AM UTC.
Dependencies resolved.
========================================================================================================================
 Package                   Architecture           Version                                  Repository              Size
========================================================================================================================
Installing:
 net-tools                 x86_64                 2.0-0.62.20160912git.el9                 baseos                 292 k

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 292 k
Installed size: 912 k
Downloading Packages:
net-tools-2.0-0.62.20160912git.el9.x86_64.rpm                                           4.4 MB/s | 292 kB     00:00
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   403 kB/s | 292 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                1/1
  Installing       : net-tools-2.0-0.62.20160912git.el9.x86_64                                                      1/1
  Running scriptlet: net-tools-2.0-0.62.20160912git.el9.x86_64                                                      1/1
  Verifying        : net-tools-2.0-0.62.20160912git.el9.x86_64                                                      1/1

Installed:
  net-tools-2.0-0.62.20160912git.el9.x86_64

Complete!
[vagrant@ansible-server ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.0.53  netmask 255.255.255.0  broadcast 172.16.0.255
        inet6 fe80::eb18:181c:eca4:1efe  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a8:65:ea  txqueuelen 1000  (Ethernet)
        RX packets 9645  bytes 11231877 (10.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2817  bytes 292510 (285.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xfe220000-fe240000

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 200.200.200.146  netmask 255.255.255.0  broadcast 200.200.200.255
        inet6 fe80::20c:29ff:fea8:65f4  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a8:65:f4  txqueuelen 1000  (Ethernet)
        RX packets 533  bytes 104632 (102.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 5683 (5.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xfda20000-fda40000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX
[vagrant@ansible-server ~]$ ansible
-bash: ansible: command not found
[vagrant@ansible-server ~]$ exit
logout
Connection to 127.0.0.1 closed.
--port 보기
PS D:\vagrant_test> netstat -an | findstr 60010
  TCP    0.0.0.0:60010          0.0.0.0:0              LISTENING
PS D:\vagrant_test> vagrant port
The forwarded ports for the machine are listed below. Please note that
these values may differ from values configured in the Vagrantfile if the
provider supports automatic port collision detection and resolution.

    22 (guest) => 60010 (host)
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.define "ansible-server" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation" do |vb|
      vb.vmx["sched.cpu.max"] = "50"
      vb.cpus = 2
      vb.memory = 3000
      vb.gui = true
      # If vb.allowlist_verified is not recognized, consider removing it or verifying plugin support
      vb.allowlist_verified = true
    end
    cfg.vm.hostname = "ansible-server"
    cfg.vm.network "public_network", ip: "200.200.200.146"
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
    cfg.vm.provision "shell", inline: "dnf -y install epel-release"
    cfg.vm.provision "shell", inline: "dnf -y install ansible"
    cfg.vm.provision "shell", inline: "dnf -y install net-tools"
  end
end

--파일 설정 후 삭제
PS D:\vagrant_test> vagrant destroy -f
==> ansible-server: Stopping the VMware VM...
==> ansible-server: Deleting the VM...

--다시 up
PS D:\vagrant_test> vagrant up
Bringing machine 'ansible-server' up with 'vmware_workstation' provider...
==> ansible-server: Cloning VMware VM: 'rockylinux/9'. This can take some time...
==> ansible-server: Checking if box 'rockylinux/9' version '3.0.0' is up to date...
==> ansible-server: Verifying vmnet devices are healthy...
==> ansible-server: Preparing network adapters...
==> ansible-server: Starting the VMware VM...
==> ansible-server: Waiting for the VM to receive an address...
==> ansible-server: Forwarding ports...
    ansible-server: -- 22 => 60010
==> ansible-server: Waiting for machine to boot. This may take a few minutes...
    ansible-server: SSH address: 127.0.0.1:60010
    ansible-server: SSH username: vagrant
    ansible-server: SSH auth method: private key
    ansible-server:
    ansible-server: Vagrant insecure key detected. Vagrant will automatically replace
    ansible-server: this with a newly generated keypair for better security.
    ansible-server:
    ansible-server: Inserting generated public key within guest...
    ansible-server: Removing insecure key from the guest if it's present...
    ansible-server: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ansible-server: Machine booted and ready!
==> ansible-server: Setting hostname...
==> ansible-server: Configuring network adapters within the VM...
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Rocky Linux 9 - BaseOS                          5.1 kB/s | 4.1 kB     00:00
    ansible-server: Rocky Linux 9 - BaseOS                          2.6 MB/s | 2.2 MB     00:00
    ansible-server: Rocky Linux 9 - AppStream                       6.1 kB/s | 4.5 kB     00:00
    ansible-server: Rocky Linux 9 - AppStream                       3.4 MB/s | 7.4 MB     00:02
    ansible-server: Rocky Linux 9 - Extras                          3.3 kB/s | 2.9 kB     00:00
    ansible-server: Rocky Linux 9 - Extras                           17 kB/s |  14 kB     00:00
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package               Architecture    Version            Repository       Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  epel-release          noarch          9-7.el9            extras           19 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  1 Package
    ansible-server:
    ansible-server: Total download size: 19 k
    ansible-server: Installed size: 26 k
    ansible-server: Downloading Packages:
    ansible-server: epel-release-9-7.el9.noarch.rpm                 164 kB/s |  19 kB     00:00
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                            21 kB/s |  19 kB     00:00
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : epel-release-9-7.el9.noarch                            1/1
    ansible-server:   Running scriptlet: epel-release-9-7.el9.noarch                            1/1
    ansible-server: Many EPEL packages require the CodeReady Builder (CRB) repository.
    ansible-server: It is recommended that you run /usr/bin/crb enable to enable the CRB repository.
    ansible-server:
    ansible-server:   Verifying        : epel-release-9-7.el9.noarch                            1/1
    ansible-server:
    ansible-server: Installed:
    ansible-server:   epel-release-9-7.el9.noarch
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Extra Packages for Enterprise Linux 9 - x86_64   18 MB/s |  21 MB     00:01
    ansible-server: Extra Packages for Enterprise Linux 9 openh264  991  B/s | 2.5 kB     00:02
    ansible-server: Last metadata expiration check: 0:00:01 ago on Thu 28 Mar 2024 02:46:03 AM UTC.
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package                  Arch       Version                Repository     Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  ansible                  noarch     1:7.7.0-1.el9          epel           34 M
    ansible-server: Installing dependencies:
    ansible-server:  ansible-core             x86_64     1:2.14.9-1.el9         appstream     2.2 M
    ansible-server:  git-core                 x86_64     2.39.3-1.el9_2         appstream     4.2 M
    ansible-server:  python3-cffi             x86_64     1.14.5-5.el9           baseos        241 k
    ansible-server:  python3-cryptography     x86_64     36.0.1-4.el9           baseos        1.2 M
    ansible-server:  python3-packaging        noarch     20.9-5.el9             appstream      69 k
    ansible-server:  python3-ply              noarch     3.11-14.el9.0.1        baseos        103 k
    ansible-server:  python3-pycparser        noarch     2.20-6.el9             baseos        124 k
    ansible-server:  python3-pyparsing        noarch     2.4.7-9.el9            baseos        150 k
    ansible-server:  python3-resolvelib       noarch     0.5.4-5.el9            appstream      29 k
    ansible-server:  python3-setuptools       noarch     53.0.0-12.el9          baseos        839 k
    ansible-server:  sshpass                  x86_64     1.09-4.el9             appstream      27 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  12 Packages
    ansible-server:
    ansible-server: Total download size: 43 M
    ansible-server: Installed size: 406 M
    ansible-server: Downloading Packages:
    ansible-server: (1/12): python3-pyparsing-2.4.7-9.el9.noarch.rp 1.0 MB/s | 150 kB     00:00
    ansible-server: (2/12): python3-setuptools-53.0.0-12.el9.noarch 4.6 MB/s | 839 kB     00:00
    ansible-server: (3/12): python3-cffi-1.14.5-5.el9.x86_64.rpm    2.1 MB/s | 241 kB     00:00
    ansible-server: (4/12): python3-ply-3.11-14.el9.0.1.noarch.rpm  1.4 MB/s | 103 kB     00:00
    ansible-server: (5/12): python3-pycparser-2.20-6.el9.noarch.rpm 1.9 MB/s | 124 kB     00:00
    ansible-server: (6/12): python3-packaging-20.9-5.el9.noarch.rpm 1.1 MB/s |  69 kB     00:00
    ansible-server: (7/12): python3-cryptography-36.0.1-4.el9.x86_6 2.9 MB/s | 1.2 MB     00:00
    ansible-server: (8/12): python3-resolvelib-0.5.4-5.el9.noarch.r 604 kB/s |  29 kB     00:00
    ansible-server: (9/12): sshpass-1.09-4.el9.x86_64.rpm           489 kB/s |  27 kB     00:00
    ansible-server: (10/12): ansible-7.7.0-1.el9.noarch.rpm          34 MB/s |  34 MB     00:00
    ansible-server: (11/12): ansible-core-2.14.9-1.el9.x86_64.rpm   5.3 MB/s | 2.2 MB     00:00
    ansible-server: (12/12): git-core-2.39.3-1.el9_2.x86_64.rpm     7.9 MB/s | 4.2 MB     00:00
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                            12 MB/s |  43 MB     00:03
    ansible-server: Extra Packages for Enterprise Linux 9 - x86_64  1.6 MB/s | 1.6 kB     00:00
    ansible-server: Importing GPG key 0x3228467C:
    ansible-server:  Userid     : "Fedora (epel9) <epel@fedoraproject.org>"
    ansible-server:  Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C
    ansible-server:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
    ansible-server: Key imported successfully
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : git-core-2.39.3-1.el9_2.x86_64                        1/12
    ansible-server:   Installing       : sshpass-1.09-4.el9.x86_64                             2/12
    ansible-server:   Installing       : python3-resolvelib-0.5.4-5.el9.noarch                 3/12
    ansible-server:   Installing       : python3-ply-3.11-14.el9.0.1.noarch                    4/12
    ansible-server:   Installing       : python3-pycparser-2.20-6.el9.noarch                   5/12
    ansible-server:   Installing       : python3-cffi-1.14.5-5.el9.x86_64                      6/12
    ansible-server:   Installing       : python3-cryptography-36.0.1-4.el9.x86_64              7/12
    ansible-server:   Installing       : python3-setuptools-53.0.0-12.el9.noarch               8/12
    ansible-server:   Installing       : python3-pyparsing-2.4.7-9.el9.noarch                  9/12
    ansible-server:   Installing       : python3-packaging-20.9-5.el9.noarch                  10/12
    ansible-server:   Installing       : ansible-core-1:2.14.9-1.el9.x86_64                   11/12
    ansible-server:   Installing       : ansible-1:7.7.0-1.el9.noarch                         12/12
    ansible-server:   Running scriptlet: ansible-1:7.7.0-1.el9.noarch                         12/12
    ansible-server:   Verifying        : ansible-1:7.7.0-1.el9.noarch                          1/12
    ansible-server:   Verifying        : python3-pyparsing-2.4.7-9.el9.noarch                  2/12
    ansible-server:   Verifying        : python3-setuptools-53.0.0-12.el9.noarch               3/12
    ansible-server:   Verifying        : python3-cryptography-36.0.1-4.el9.x86_64              4/12
    ansible-server:   Verifying        : python3-cffi-1.14.5-5.el9.x86_64                      5/12
    ansible-server:   Verifying        : python3-ply-3.11-14.el9.0.1.noarch                    6/12
    ansible-server:   Verifying        : python3-pycparser-2.20-6.el9.noarch                   7/12
    ansible-server:   Verifying        : python3-packaging-20.9-5.el9.noarch                   8/12
    ansible-server:   Verifying        : python3-resolvelib-0.5.4-5.el9.noarch                 9/12
    ansible-server:   Verifying        : sshpass-1.09-4.el9.x86_64                            10/12
    ansible-server:   Verifying        : git-core-2.39.3-1.el9_2.x86_64                       11/12
    ansible-server:   Verifying        : ansible-core-1:2.14.9-1.el9.x86_64                   12/12
    ansible-server:
    ansible-server: Installed:
    ansible-server:   ansible-1:7.7.0-1.el9.noarch
    ansible-server:   ansible-core-1:2.14.9-1.el9.x86_64
    ansible-server:   git-core-2.39.3-1.el9_2.x86_64
    ansible-server:   python3-cffi-1.14.5-5.el9.x86_64
    ansible-server:   python3-cryptography-36.0.1-4.el9.x86_64
    ansible-server:   python3-packaging-20.9-5.el9.noarch
    ansible-server:   python3-ply-3.11-14.el9.0.1.noarch
    ansible-server:   python3-pycparser-2.20-6.el9.noarch
    ansible-server:   python3-pyparsing-2.4.7-9.el9.noarch
    ansible-server:   python3-resolvelib-0.5.4-5.el9.noarch
    ansible-server:   python3-setuptools-53.0.0-12.el9.noarch
    ansible-server:   sshpass-1.09-4.el9.x86_64
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Last metadata expiration check: 0:00:22 ago on Thu 28 Mar 2024 02:46:03 AM UTC.
    ansible-server: No match for argument: net-tolls
    ansible-server: Error: Unable to find a match: net-tolls
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

--vagrant status
PS D:\vagrant_test> vagrant status
Current machine states:

ansible-server            running (vmware_workstation)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.

--ssh 접근
PS D:\vagrant_test> vagrant ssh ansible-server
[vagrant@ansible-server ~]$

--ansible 실행 확인
[vagrant@ansible-server ~]$ ansible
usage: ansible [-h] [--version] [-v] [-b] [--become-method BECOME_METHOD] [--become-user BECOME_USER]
               [-K | --become-password-file BECOME_PASSWORD_FILE] [-i INVENTORY] [--list-hosts] [-l SUBSET]
               [-P POLL_INTERVAL] [-B SECONDS] [-o] [-t TREE] [--private-key PRIVATE_KEY_FILE] [-u REMOTE_USER]
               [-c CONNECTION] [-T TIMEOUT] [--ssh-common-args SSH_COMMON_ARGS] [--sftp-extra-args SFTP_EXTRA_ARGS]
               [--scp-extra-args SCP_EXTRA_ARGS] [--ssh-extra-args SSH_EXTRA_ARGS]
               [-k | --connection-password-file CONNECTION_PASSWORD_FILE] [-C] [-D] [-e EXTRA_VARS]
               [--vault-id VAULT_IDS] [--ask-vault-password | --vault-password-file VAULT_PASSWORD_FILES] [-f FORKS]
               [-M MODULE_PATH] [--playbook-dir BASEDIR] [--task-timeout TASK_TIMEOUT] [-a MODULE_ARGS]
               [-m MODULE_NAME]
               pattern
ansible: error: the following arguments are required: pattern
~~

---
- name: Setup for the Ansible's Environment
  hosts: localhost
  gather_facts: no
  
  tasks:
    - name: Create vim env's directories & files
      shell: "{{ item }}"
      with_items:
        - "mkdir -p /home/vagrant/.vim/autoload /home/vagrant/.vim/bundle"
        - "touch /home/vagrant/.vimrc"
        - "touch /home/vagrant/.bashrc"
      
    - name: Install vim-enhanced
      yum: 
        name: vim-enhanced
        state: present
        
    - name: Install git
      yum: 
        name: git
        state: present
        
    - name: Download pathogen.vim
      shell: "curl -fLo /home/vagrant/.vim/autoload/pathogen.vim
              https://tpo.pe/pathogen.vim"
      
    - name: Git clone vim-ansible-yaml
      git:
        repo: https://github.com/chase/vim-ansible-yaml.git
        dest: /home/vagrant/.vim/bundle/vim-ansible-yaml
        
    - name: Configure vimrc
      lineinfile: 
        path: /home/vagrant/.vimrc
        line: "{{ item }}"
      with_items:
        - "set number"
        - "execute pathogen#infect()"
        - "syntax on"

    - name: Configure Bashrc
      lineinfile:   
        path: /home/vagrant/.bashrc
        line: "{{ item }}"
      with_items:
        - "alias ans='ansible'"
        - "alias anp='ansible-playbook'"

PS D:\vagrant_test> vagrant up
Bringing machine 'ansible-server' up with 'vmware_workstation' provider...
==> ansible-server: Cloning VMware VM: 'rockylinux/9'. This can take some time...
==> ansible-server: Checking if box 'rockylinux/9' version '3.0.0' is up to date...
==> ansible-server: Verifying vmnet devices are healthy...
==> ansible-server: Preparing network adapters...
==> ansible-server: Starting the VMware VM...
==> ansible-server: Waiting for the VM to receive an address...
==> ansible-server: Forwarding ports...
    ansible-server: -- 22 => 60010
==> ansible-server: Waiting for machine to boot. This may take a few minutes...
    ansible-server: SSH address: 127.0.0.1:60010
    ansible-server: SSH username: vagrant
    ansible-server: SSH auth method: private key
    ansible-server:
    ansible-server: Vagrant insecure key detected. Vagrant will automatically replace
    ansible-server: this with a newly generated keypair for better security.
    ansible-server:
    ansible-server: Inserting generated public key within guest...
    ansible-server: Removing insecure key from the guest if it's present...
    ansible-server: Key inserted! Disconnecting and reconnecting using new SSH key...
==> ansible-server: Machine booted and ready!
==> ansible-server: Setting hostname...
==> ansible-server: Configuring network adapters within the VM...
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Rocky Linux 9 - BaseOS                          4.7 kB/s | 4.1 kB     00:00
    ansible-server: Rocky Linux 9 - BaseOS                          1.4 MB/s | 2.2 MB     00:01
    ansible-server: Rocky Linux 9 - AppStream                       5.1 kB/s | 4.5 kB     00:00
    ansible-server: Rocky Linux 9 - AppStream                       8.6 MB/s | 7.4 MB     00:00
    ansible-server: Rocky Linux 9 - Extras                          3.7 kB/s | 2.9 kB     00:00
    ansible-server: Rocky Linux 9 - Extras                           14 kB/s |  14 kB     00:01
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package               Architecture    Version            Repository       Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  epel-release          noarch          9-7.el9            extras           19 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  1 Package
    ansible-server:
    ansible-server: Total download size: 19 k
    ansible-server: Installed size: 26 k
    ansible-server: Downloading Packages:
    ansible-server: epel-release-9-7.el9.noarch.rpm                 157 kB/s |  19 kB     00:00
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                            23 kB/s |  19 kB     00:00
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : epel-release-9-7.el9.noarch                            1/1
    ansible-server:   Running scriptlet: epel-release-9-7.el9.noarch                            1/1
    ansible-server: Many EPEL packages require the CodeReady Builder (CRB) repository.
    ansible-server: It is recommended that you run /usr/bin/crb enable to enable the CRB repository.
    ansible-server:
    ansible-server:   Verifying        : epel-release-9-7.el9.noarch                            1/1
    ansible-server:
    ansible-server: Installed:
    ansible-server:   epel-release-9-7.el9.noarch
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Extra Packages for Enterprise Linux 9 - x86_64   13 MB/s |  21 MB     00:01
    ansible-server: Extra Packages for Enterprise Linux 9 openh264  921  B/s | 2.5 kB     00:02
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package                  Arch       Version                Repository     Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  ansible                  noarch     1:7.7.0-1.el9          epel           34 M
    ansible-server: Installing dependencies:
    ansible-server:  ansible-core             x86_64     1:2.14.9-1.el9         appstream     2.2 M
    ansible-server:  git-core                 x86_64     2.39.3-1.el9_2         appstream     4.2 M
    ansible-server:  python3-cffi             x86_64     1.14.5-5.el9           baseos        241 k
    ansible-server:  python3-cryptography     x86_64     36.0.1-4.el9           baseos        1.2 M
    ansible-server:  python3-packaging        noarch     20.9-5.el9             appstream      69 k
    ansible-server:  python3-ply              noarch     3.11-14.el9.0.1        baseos        103 k
    ansible-server:  python3-pycparser        noarch     2.20-6.el9             baseos        124 k
    ansible-server:  python3-pyparsing        noarch     2.4.7-9.el9            baseos        150 k
    ansible-server:  python3-resolvelib       noarch     0.5.4-5.el9            appstream      29 k
    ansible-server:  python3-setuptools       noarch     53.0.0-12.el9          baseos        839 k
    ansible-server:  sshpass                  x86_64     1.09-4.el9             appstream      27 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  12 Packages
    ansible-server:
    ansible-server: Total download size: 43 M
    ansible-server: Installed size: 406 M
    ansible-server: Downloading Packages:
    ansible-server: (1/12): python3-setuptools-53.0.0-12.el9.noarch 4.6 MB/s | 839 kB     00:00
    ansible-server: (2/12): python3-pyparsing-2.4.7-9.el9.noarch.rp 834 kB/s | 150 kB     00:00
    ansible-server: (3/12): python3-cffi-1.14.5-5.el9.x86_64.rpm     11 MB/s | 241 kB     00:00
    ansible-server: (4/12): python3-cryptography-36.0.1-4.el9.x86_6  39 MB/s | 1.2 MB     00:00
    ansible-server: (5/12): python3-ply-3.11-14.el9.0.1.noarch.rpm   11 MB/s | 103 kB     00:00
    ansible-server: (6/12): python3-pycparser-2.20-6.el9.noarch.rpm  12 MB/s | 124 kB     00:00
    ansible-server: (7/12): python3-packaging-20.9-5.el9.noarch.rpm 4.7 MB/s |  69 kB     00:00
    ansible-server: (8/12): python3-resolvelib-0.5.4-5.el9.noarch.r 1.5 MB/s |  29 kB     00:00
    ansible-server: (9/12): sshpass-1.09-4.el9.x86_64.rpm           1.5 MB/s |  27 kB     00:00
    ansible-server: (10/12): git-core-2.39.3-1.el9_2.x86_64.rpm      51 MB/s | 4.2 MB     00:00
    ansible-server: (11/12): ansible-core-2.14.9-1.el9.x86_64.rpm   8.2 MB/s | 2.2 MB     00:00
    ansible-server: (12/12): ansible-7.7.0-1.el9.noarch.rpm          26 MB/s |  34 MB     00:01
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                            12 MB/s |  43 MB     00:03
    ansible-server: Extra Packages for Enterprise Linux 9 - x86_64  1.6 MB/s | 1.6 kB     00:00
    ansible-server: Importing GPG key 0x3228467C:
    ansible-server:  Userid     : "Fedora (epel9) <epel@fedoraproject.org>"
    ansible-server:  Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C
    ansible-server:  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
    ansible-server: Key imported successfully
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : git-core-2.39.3-1.el9_2.x86_64                        1/12
    ansible-server:   Installing       : sshpass-1.09-4.el9.x86_64                             2/12
    ansible-server:   Installing       : python3-resolvelib-0.5.4-5.el9.noarch                 3/12
    ansible-server:   Installing       : python3-ply-3.11-14.el9.0.1.noarch                    4/12
    ansible-server:   Installing       : python3-pycparser-2.20-6.el9.noarch                   5/12
    ansible-server:   Installing       : python3-cffi-1.14.5-5.el9.x86_64                      6/12
    ansible-server:   Installing       : python3-cryptography-36.0.1-4.el9.x86_64              7/12
    ansible-server:   Installing       : python3-setuptools-53.0.0-12.el9.noarch               8/12
    ansible-server:   Installing       : python3-pyparsing-2.4.7-9.el9.noarch                  9/12
    ansible-server:   Installing       : python3-packaging-20.9-5.el9.noarch                  10/12
    ansible-server:   Installing       : ansible-core-1:2.14.9-1.el9.x86_64                   11/12
    ansible-server:   Installing       : ansible-1:7.7.0-1.el9.noarch                         12/12
    ansible-server:   Running scriptlet: ansible-1:7.7.0-1.el9.noarch                         12/12
    ansible-server:   Verifying        : ansible-1:7.7.0-1.el9.noarch                          1/12
    ansible-server:   Verifying        : python3-pyparsing-2.4.7-9.el9.noarch                  2/12
    ansible-server:   Verifying        : python3-setuptools-53.0.0-12.el9.noarch               3/12
    ansible-server:   Verifying        : python3-cryptography-36.0.1-4.el9.x86_64              4/12
    ansible-server:   Verifying        : python3-cffi-1.14.5-5.el9.x86_64                      5/12
    ansible-server:   Verifying        : python3-ply-3.11-14.el9.0.1.noarch                    6/12
    ansible-server:   Verifying        : python3-pycparser-2.20-6.el9.noarch                   7/12
    ansible-server:   Verifying        : python3-packaging-20.9-5.el9.noarch                   8/12
    ansible-server:   Verifying        : python3-resolvelib-0.5.4-5.el9.noarch                 9/12
    ansible-server:   Verifying        : sshpass-1.09-4.el9.x86_64                            10/12
    ansible-server:   Verifying        : git-core-2.39.3-1.el9_2.x86_64                       11/12
    ansible-server:   Verifying        : ansible-core-1:2.14.9-1.el9.x86_64                   12/12
    ansible-server:
    ansible-server: Installed:
    ansible-server:   ansible-1:7.7.0-1.el9.noarch
    ansible-server:   ansible-core-1:2.14.9-1.el9.x86_64
    ansible-server:   git-core-2.39.3-1.el9_2.x86_64
    ansible-server:   python3-cffi-1.14.5-5.el9.x86_64
    ansible-server:   python3-cryptography-36.0.1-4.el9.x86_64
    ansible-server:   python3-packaging-20.9-5.el9.noarch
    ansible-server:   python3-ply-3.11-14.el9.0.1.noarch
    ansible-server:   python3-pycparser-2.20-6.el9.noarch
    ansible-server:   python3-pyparsing-2.4.7-9.el9.noarch
    ansible-server:   python3-resolvelib-0.5.4-5.el9.noarch
    ansible-server:   python3-setuptools-53.0.0-12.el9.noarch
    ansible-server:   sshpass-1.09-4.el9.x86_64
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Last metadata expiration check: 0:00:21 ago on Thu 28 Mar 2024 03:14:17 AM UTC.
    ansible-server: Dependencies resolved.
    ansible-server: ================================================================================
    ansible-server:  Package         Architecture Version                        Repository    Size
    ansible-server: ================================================================================
    ansible-server: Installing:
    ansible-server:  net-tools       x86_64       2.0-0.62.20160912git.el9       baseos       292 k
    ansible-server:
    ansible-server: Transaction Summary
    ansible-server: ================================================================================
    ansible-server: Install  1 Package
    ansible-server:
    ansible-server: Total download size: 292 k
    ansible-server: Installed size: 912 k
    ansible-server: Downloading Packages:
    ansible-server: net-tools-2.0-0.62.20160912git.el9.x86_64.rpm   1.8 MB/s | 292 kB     00:00
    ansible-server: --------------------------------------------------------------------------------
    ansible-server: Total                                           323 kB/s | 292 kB     00:00
    ansible-server: Running transaction check
    ansible-server: Transaction check succeeded.
    ansible-server: Running transaction test
    ansible-server: Transaction test succeeded.
    ansible-server: Running transaction
    ansible-server:   Preparing        :                                                        1/1
    ansible-server:   Installing       : net-tools-2.0-0.62.20160912git.el9.x86_64              1/1
    ansible-server:   Running scriptlet: net-tools-2.0-0.62.20160912git.el9.x86_64              1/1
    ansible-server:   Verifying        : net-tools-2.0-0.62.20160912git.el9.x86_64              1/1
    ansible-server:
    ansible-server: Installed:
    ansible-server:   net-tools-2.0-0.62.20160912git.el9.x86_64
    ansible-server:
    ansible-server: Complete!
==> ansible-server: Running provisioner: file...
    ansible-server: ansible_env_ready.yml => ansible_env_ready.yml
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: [WARNING]: provided hosts list is empty, only localhost is available. Note that
    ansible-server: the implicit localhost does not match 'all'
    ansible-server:
    ansible-server: PLAY [Setup for the Ansible's Environment] *************************************
    ansible-server:
    ansible-server: TASK [Create vim env's directories & files] ************************************
    ansible-server: changed: [localhost] => (item=mkdir -p /home/vagrant/.vim/autoload /home/vagrant/.vim/bundle)
    ansible-server: changed: [localhost] => (item=touch /home/vagrant/.vimrc)
    ansible-server: changed: [localhost] => (item=touch /home/vagrant/.bashrc)
    ansible-server:
    ansible-server: TASK [Install vim-enhanced] ****************************************************
    ansible-server: changed: [localhost]
    ansible-server:
    ansible-server: TASK [Install git] *************************************************************
    ansible-server: changed: [localhost]
    ansible-server:
    ansible-server: TASK [Download pathogen.vim] ***************************************************
    ansible-server: changed: [localhost]
    ansible-server:
    ansible-server: TASK [Git clone vim-ansible-yaml] **********************************************
    ansible-server: changed: [localhost]
    ansible-server:
    ansible-server: TASK [Configure vimrc] *********************************************************
    ansible-server: changed: [localhost] => (item=set number)
    ansible-server: changed: [localhost] => (item=execute pathogen#infect())
    ansible-server: changed: [localhost] => (item=syntax on)
    ansible-server:
    ansible-server: TASK [Configure Bashrc] ********************************************************
    ansible-server: changed: [localhost] => (item=alias ans='ansible')
    ansible-server: changed: [localhost] => (item=alias anp='ansible-playbook')
    ansible-server:
    ansible-server: PLAY RECAP *********************************************************************
    ansible-server: localhost                  : ok=7    changed=7    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
    ansible-server:
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  # Define ansible-node02
  config.vm.define "ansible-node02" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation"
    cfg.vm.network "public_network", ip: "200.200.200.148"
    cfg.vm.network "forwarded_port", guest: 22, host: 60012, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end

  # Define ansible-node01
  config.vm.define "ansible-node01" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation"
    cfg.vm.network "public_network", ip: "200.200.200.147"
    cfg.vm.network "forwarded_port", guest: 22, host: 60011, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end

  # Define ansible-server
  config.vm.define "ansible-server" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation"
    cfg.vm.hostname = "ansible-server"
    cfg.vm.network "public_network", ip: "200.200.200.146"
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true

    # Provisioning
    cfg.vm.provision "shell", inline: "dnf -y install epel-release"
    cfg.vm.provision "shell", inline: "dnf -y install ansible"
    cfg.vm.provision "shell", inline: "dnf -y install net-tools"
    cfg.vm.provision "file", source: "ansible_env_ready.yml", destination: "ansible_env_ready.yml"
    cfg.vm.provision "shell", inline: "ansible-playbook ansible_env_ready.yml"
  end

end
--node 추가
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  # Define ansible-node02
  config.vm.define "ansible-node02" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.hostname = "ansible-node02"
    cfg.vm.network "public_network", ip: "200.200.200.148"
    cfg.vm.network "forwarded_port", guest: 22, host: 60012, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end

  # Define ansible-node01
  config.vm.define "ansible-node01" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.hostname = "ansible-node01"
    cfg.vm.network "public_network", ip: "200.200.200.147"
    cfg.vm.network "forwarded_port", guest: 22, host: 60011, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
  end

  # Define ansible-server
  config.vm.define "ansible-server" do |cfg|
    cfg.vm.box = "rockylinux/9"
    cfg.vm.provider "vmware_workstation" do |vb|
      # Note: `vb.vmx["sched.cpu.max"] = "50"` might not be necessary or correct for all setups.
      vb.vmx["sched.cpu.max"] = "50"
      vb.cpus = 2
      vb.memory = 3000
      vb.gui = true
      # The `vb.allowlist_verified` property might not be recognized. Commented out for safety.
      # vb.allowlist_verified = true
    end
    cfg.vm.hostname = "ansible-server"
    cfg.vm.network "public_network", ip: "200.200.200.146"
    cfg.vm.network "forwarded_port", guest: 22, host: 60010, auto_correct: true, id: "ssh"
    cfg.vm.synced_folder "../data", "/vagrant", disabled: true
    # Provisioning 
    cfg.vm.provision "shell", inline: <<-SHELL
      dnf install epel-release -y
      dnf install ansible -y
      dnf install net-tools -y
    SHELL
    cfg.vm.provision "file", source: "ansible_env_ready.yml", destination: "ansible_env_ready.yml"
    cfg.vm.provision "shell", inline: "ansible-playbook ansible_env_ready.yml"
  end   
end
--ansible 제어
[vagrant@ansible-server ~]$ ansible all -m ping
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'
--yml task에 node 주소 추가
    - name: Add "/etc/ansible/hosts"
      blockinfile: 
        path: /etc/ansible/hosts
        block: |
          [rocky]
          200.200.200.147
          200.200.200.148
          
--변경된 부분만 다시
PS D:\vagrant_test> vagrant provision
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: Last metadata expiration check: 0:08:20 ago on Thu 28 Mar 2024 04:38:56 AM UTC.
    ansible-server: Package epel-release-9-7.el9.noarch is already installed.
    ansible-server: Dependencies resolved.
    ansible-server: Nothing to do.
    ansible-server: Complete!
    ansible-server: Last metadata expiration check: 0:08:21 ago on Thu 28 Mar 2024 04:38:56 AM UTC.
    ansible-server: Package ansible-1:7.7.0-1.el9.noarch is already installed.
    ansible-server: Dependencies resolved.
    ansible-server: Nothing to do.
    ansible-server: Complete!
    ansible-server: Last metadata expiration check: 0:08:21 ago on Thu 28 Mar 2024 04:38:56 AM UTC.
    ansible-server: Package net-tools-2.0-0.62.20160912git.el9.x86_64 is already installed.
    ansible-server: Dependencies resolved.
    ansible-server: Nothing to do.
    ansible-server: Complete!
==> ansible-server: Running provisioner: file...
    ansible-server: ansible_env_ready.yml => ansible_env_ready.yml
==> ansible-server: Running provisioner: shell...
    ansible-server: Running: inline script
    ansible-server: [WARNING]: provided hosts list is empty, only localhost is available. Note that
    ansible-server: the implicit localhost does not match 'all'
    ansible-server:
    ansible-server: PLAY [Setup for the Ansible's Environment] *************************************
    ansible-server:
    ansible-server: TASK [Add "/etc/ansible/hosts"] ************************************************
    ansible-server: changed: [localhost]
    ansible-server:
    ansible-server: TASK [Create vim env's directories & files] ************************************
    ansible-server: changed: [localhost] => (item=mkdir -p /home/vagrant/.vim/autoload /home/vagrant/.vim/bundle)
    ansible-server: changed: [localhost] => (item=touch /home/vagrant/.vimrc)
    ansible-server: changed: [localhost] => (item=touch /home/vagrant/.bashrc)
    ansible-server:
    ansible-server: TASK [Install vim-enhanced] ****************************************************
    ansible-server: ok: [localhost]
    ansible-server:
    ansible-server: TASK [Install git] *************************************************************
    ansible-server: ok: [localhost]
    ansible-server:
    ansible-server: TASK [Download pathogen.vim] ***************************************************
    ansible-server: changed: [localhost]
    ansible-server:
    ansible-server: TASK [Git clone vim-ansible-yaml] **********************************************
    ansible-server: ok: [localhost]
    ansible-server:
    ansible-server: TASK [Configure vimrc] *********************************************************
    ansible-server: ok: [localhost] => (item=set number)
    ansible-server: ok: [localhost] => (item=execute pathogen#infect())
    ansible-server: ok: [localhost] => (item=syntax on)
    ansible-server:
    ansible-server: TASK [Configure Bashrc] ********************************************************
    ansible-server: ok: [localhost] => (item=alias ans='ansible')
    ansible-server: ok: [localhost] => (item=alias anp='ansible-playbook')
    ansible-server:
    ansible-server: PLAY RECAP *********************************************************************
    ansible-server: localhost                  : ok=8    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
    ansible-server:
--오류 발생
[vagrant@ansible-server ~]$ ansible all -m ping
The authenticity of host '200.200.200.148 (200.200.200.148)' can't be established.
ED25519 key fingerprint is SHA256:KR8CIqOO4zTx8mqpcXGUbL30kZZm9oarMWuF5HQeTZ0.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? 200.200.200.147 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: vagrant@200.200.200.147: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
    "unreachable": true
}

200.200.200.148 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Host key verification failed.",
    "unreachable": true
}
-- -k 옵션
PS D:\vagrant_test> vagrant ssh ansible-server
Last login: Thu Mar 28 05:00:37 2024 from 172.16.0.254
[vagrant@ansible-server ~]$ ls -al
total 24
drwx------. 5 vagrant vagrant  166 Mar 28 04:43 .
drwxr-xr-x. 3 root    root      21 Nov 13 16:33 ..
drwxr-xr-x. 4 vagrant vagrant   27 Mar 28 04:47 .ansible
-rw-r--r--. 1 vagrant vagrant 1512 Mar 28 05:02 ansible_env_ready.yml
-rw-------. 1 vagrant vagrant  276 Mar 28 05:02 .bash_history
-rw-r--r--. 1 vagrant vagrant   18 Jan 23  2023 .bash_logout
-rw-r--r--. 1 vagrant vagrant  141 Jan 23  2023 .bash_profile
-rw-r--r--. 1 vagrant vagrant  541 Mar 28 05:03 .bashrc
drwx------. 2 vagrant vagrant   71 Mar 28 04:56 .ssh
drwxr-xr-x. 4 root    root      36 Mar 28 04:39 .vim
-rw-r--r--. 1 root    root      47 Mar 28 05:03 .vimrc
[vagrant@ansible-server ~]$ cd .ssh
[vagrant@ansible-server .ssh]$ ls
authorized_keys  known_hosts  known_hosts.old
[vagrant@ansible-server .ssh]$ cat authorized_keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHcATcH90A4fnZjiOacxsbv/9mMNfPdABq+4rBfB/uJT vagrant
[vagrant@ansible-server .ssh]$ cat known_hosts
200.200.200.147 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHWbn/naRwRTkgF0PdNmOJwhdi+CcDMGoT9OwOhAKZ6j
200.200.200.147 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC4xdKMZTbhGUN7O2UeKU24QAcXqdIkNfecFLDoRH2rtohkn0jdEe6ObdxxDNdjpvq1GPANYFYk1tl5NN9N4E7495X1msA5v3ix/31CN3qk6TElkFz0X6Jk66IK4LEY7S4InyW2o5ur5f/FNpxK2jp9VKdJxLOfTwElGZxiD0qMiumPTK2kEYdCO9anNj7DMLfJO1LXIgKlZJ4wSq+4Qp190042e2Lft80R/Y+F2rO90p5psKA83hx+Xn64XBBlv+c4FSbTgRE3bEdhVyv+LrqOmRcCzd6KIyNsRl/uKFrK1+DxGLhGk6w/dI8ELbldn4xAM34CbmV0awGqLVR1pb9ea6DdPVJpgKIknPoVVpWJ91JZBW4uKWB5LUe0hFXjpgzTsobnbErrAZ9ACsXaauNGZsndCOgnArHd+/EU0PkYDTteOMUqVQqERUpZt4hQkj6YCEOt/JPAMR8g3YcGPPxrVBRRdfvmrB+OEhElkVZkjEpyBDdEiRXv4xNdTJJUHFk=
200.200.200.147 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFQPvXEr98sLEABgX2De5NoyNJKWTI57U/eEsLjo6DDS7BzhhcLcama9hBccuH6/8yGauum9y74XVdb/jCCC1Dc=
--내용 제거
[vagrant@ansible-server .ssh]$ vi known_hosts
[vagrant@ansible-server .ssh]$ ansible all -m ping
The authenticity of host '200.200.200.148 (200.200.200.148)' can't be established.
ED25519 key fingerprint is SHA256:KR8CIqOO4zTx8mqpcXGUbL30kZZm9oarMWuF5HQeTZ0.
This key is not known by any other names
The authenticity of host '200.200.200.147 (200.200.200.147)' can't be established.
ED25519 key fingerprint is SHA256:BS8qpnXbXcvNBaIHsm/FBWx7Bo/NJ/AnpjmdnRgG1uQ.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
200.200.200.148 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '200.200.200.148' (ED25519) to the list of known hosts.\r\nvagrant@200.200.200.148: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
    "unreachable": true
}
yes
200.200.200.147 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '200.200.200.147' (ED25519) to the list of known hosts.\r\nvagrant@200.200.200.147: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
    "unreachable": true
}
[vagrant@ansible-server .ssh]$ ansible all -m ping -k
SSH password:
200.200.200.147 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}
200.200.200.148 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}
PS D:\vagrant_test> vagrant destroy -f
==> ansible-server: Stopping the VMware VM...
==> ansible-server: Deleting the VM...
==> ansible-node01: Stopping the VMware VM...
==> ansible-node01: Deleting the VM...
==> ansible-node02: Stopping the VMware VM...
==> ansible-node02: Deleting the VM...

--shell file 생성 add_sshd_auth.sh
#! /usr/bin/env bash
# -p : 암호
# -T : 원격지 실행시 pts(pseudo tty 제공 X)
# -o :  StrictHostKeyChecking=no  사용자 실행없이 확인
#ssh key 생성
sshpass -p vagrant ssh -T -o StrictHostKeyChecking=no vagrant@200.200.200.147
sshpass -p vagrant ssh -T -o StrictHostKeyChecking=no vagrant@200.200.200.148

--Vagrantfile
    SHELL
    cfg.vm.provision "file", source: "ansible_env_ready.yml", destination: "ansible_env_ready.yml"
    cfg.vm.provision "shell", inline: "ansible-playbook ansible_env_ready.yml"
    cfg.vm.provision "shell", path: "add_sshd_auth.sh", privileged: faulse 	# 추가
    
--yml
    - name: Install sshpass for Authentication
      dnf:
        name: sshpass
        state: present
PS D:\vagrant_test> vagrant up Bringing machine 'ansible-node02' up with 'vmware_desktop' provider... Bringing machine 'ansible-node01' up with 'vmware_desktop' provider... Bringing machine 'ansible-server' up with 'vmware_workstation' provider... ==> ansible-node02: Cloning VMware VM: 'rockylinux/9'. This can take some time... ==> ansible-node02: Checking if box 'rockylinux/9' version '3.0.0' is up to date... ==> ansible-node02: Verifying vmnet devices are healthy... ==> ansible-node02: Preparing network adapters... ==> ansible-node02: Starting the VMware VM... ==> ansible-node02: Waiting for the VM to receive an address... ==> ansible-node02: Forwarding ports... ansible-node02: -- 22 => 60012 ==> ansible-node02: Waiting for machine to boot. This may take a few minutes... ansible-node02: SSH address: 127.0.0.1:60012 ansible-node02: SSH username: vagrant ansible-node02: SSH auth method: private key ansible-node02: ansible-node02: Vagrant insecure key detected. Vagrant will automatically replace ansible-node02: this with a newly generated keypair for better security. ansible-node02: ansible-node02: Inserting generated public key within guest... ansible-node02: Removing insecure key from the guest if it's present... ansible-node02: Key inserted! Disconnecting and reconnecting using new SSH key... ==> ansible-node02: Machine booted and ready! ==> ansible-node02: Setting hostname... ==> ansible-node02: Configuring network adapters within the VM... ==> ansible-node01: Cloning VMware VM: 'rockylinux/9'. This can take some time... ==> ansible-node01: Checking if box 'rockylinux/9' version '3.0.0' is up to date... ==> ansible-node01: Verifying vmnet devices are healthy... ==> ansible-node01: Preparing network adapters... ==> ansible-node01: Starting the VMware VM... ==> ansible-node01: Waiting for the VM to receive an address... ==> ansible-node01: Forwarding ports... ansible-node01: -- 22 => 60011 ==> ansible-node01: Waiting for machine to boot. This may take a few minutes... ansible-node01: SSH address: 127.0.0.1:60011 ansible-node01: SSH username: vagrant ansible-node01: SSH auth method: private key ansible-node01: ansible-node01: Vagrant insecure key detected. Vagrant will automatically replace ansible-node01: this with a newly generated keypair for better security. ansible-node01: ansible-node01: Inserting generated public key within guest... ansible-node01: Removing insecure key from the guest if it's present... ansible-node01: Key inserted! Disconnecting and reconnecting using new SSH key... ==> ansible-node01: Machine booted and ready! ==> ansible-node01: Setting hostname... ==> ansible-node01: Configuring network adapters within the VM... ==> ansible-server: Cloning VMware VM: 'rockylinux/9'. This can take some time... ==> ansible-server: Checking if box 'rockylinux/9' version '3.0.0' is up to date... ==> ansible-server: Verifying vmnet devices are healthy... ==> ansible-server: Preparing network adapters... ==> ansible-server: Starting the VMware VM... ==> ansible-server: Waiting for the VM to receive an address... ==> ansible-server: Forwarding ports... ansible-server: -- 22 => 60010 ==> ansible-server: Waiting for machine to boot. This may take a few minutes... ansible-server: SSH address: 127.0.0.1:60010 ansible-server: SSH username: vagrant ansible-server: SSH auth method: private key ansible-server: ansible-server: Vagrant insecure key detected. Vagrant will automatically replace ansible-server: this with a newly generated keypair for better security. ansible-server: ansible-server: Inserting generated public key within guest... ansible-server: Removing insecure key from the guest if it's present... ansible-server: Key inserted! Disconnecting and reconnecting using new SSH key... ==> ansible-server: Machine booted and ready! ==> ansible-server: Setting hostname... ==> ansible-server: Configuring network adapters within the VM... ==> ansible-server: Running provisioner: shell... ansible-server: Running: inline script ansible-server: Rocky Linux 9 - BaseOS 4.5 kB/s | 4.1 kB 00:00 ansible-server: Rocky Linux 9 - BaseOS 2.3 MB/s | 2.2 MB 00:00 ansible-server: Rocky Linux 9 - AppStream 5.6 kB/s | 4.5 kB 00:00 ansible-server: Rocky Linux 9 - AppStream 5.0 MB/s | 7.4 MB 00:01 ansible-server: Rocky Linux 9 - Extras 4.0 kB/s | 2.9 kB 00:00 ansible-server: Rocky Linux 9 - Extras 15 kB/s | 14 kB 00:00 ansible-server: Dependencies resolved. ansible-server: ================================================================================ ansible-server: Package Architecture Version Repository Size ansible-server: ================================================================================ ansible-server: Installing: ansible-server: epel-release noarch 9-7.el9 extras 19 k ansible-server: ansible-server: Transaction Summary ansible-server: ================================================================================ ansible-server: Install 1 Package ansible-server: ansible-server: Total download size: 19 k ansible-server: Installed size: 26 k ansible-server: Downloading Packages: ansible-server: epel-release-9-7.el9.noarch.rpm 11 kB/s | 19 kB 00:01 ansible-server: -------------------------------------------------------------------------------- ansible-server: Total 7.8 kB/s | 19 kB 00:02 ansible-server: Running transaction check ansible-server: Transaction check succeeded. ansible-server: Running transaction test ansible-server: Transaction test succeeded. ansible-server: Running transaction ansible-server: Preparing : 1/1 ansible-server: Installing : epel-release-9-7.el9.noarch 1/1 ansible-server: Running scriptlet: epel-release-9-7.el9.noarch 1/1 ansible-server: Many EPEL packages require the CodeReady Builder (CRB) repository. ansible-server: It is recommended that you run /usr/bin/crb enable to enable the CRB repository. ansible-server: ansible-server: Verifying : epel-release-9-7.el9.noarch 1/1 ansible-server: ansible-server: Installed: ansible-server: epel-release-9-7.el9.noarch ansible-server: ansible-server: Complete! ansible-server: Extra Packages for Enterprise Linux 9 - x86_64 10 MB/s | 21 MB 00:02 ansible-server: Extra Packages for Enterprise Linux 9 openh264 1.3 kB/s | 2.5 kB 00:01 ansible-server: Dependencies resolved. ansible-server: ================================================================================ ansible-server: Package Arch Version Repository Size ansible-server: ================================================================================ ansible-server: Installing: ansible-server: ansible noarch 1:7.7.0-1.el9 epel 34 M ansible-server: Installing dependencies: ansible-server: ansible-core x86_64 1:2.14.9-1.el9 appstream 2.2 M ansible-server: git-core x86_64 2.39.3-1.el9_2 appstream 4.2 M ansible-server: python3-cffi x86_64 1.14.5-5.el9 baseos 241 k ansible-server: python3-cryptography x86_64 36.0.1-4.el9 baseos 1.2 M ansible-server: python3-packaging noarch 20.9-5.el9 appstream 69 k ansible-server: python3-ply noarch 3.11-14.el9.0.1 baseos 103 k ansible-server: python3-pycparser noarch 2.20-6.el9 baseos 124 k ansible-server: python3-pyparsing noarch 2.4.7-9.el9 baseos 150 k ansible-server: python3-resolvelib noarch 0.5.4-5.el9 appstream 29 k ansible-server: python3-setuptools noarch 53.0.0-12.el9 baseos 839 k ansible-server: sshpass x86_64 1.09-4.el9 appstream 27 k ansible-server: ansible-server: Transaction Summary ansible-server: ================================================================================ ansible-server: Install 12 Packages ansible-server: ansible-server: Total download size: 43 M ansible-server: Installed size: 406 M ansible-server: Downloading Packages: ansible-server: (1/12): python3-pyparsing-2.4.7-9.el9.noarch.rp 1.0 MB/s | 150 kB 00:00 ansible-server: (2/12): python3-setuptools-53.0.0-12.el9.noarch 4.1 MB/s | 839 kB 00:00 ansible-server: (3/12): python3-cffi-1.14.5-5.el9.x86_64.rpm 1.9 MB/s | 241 kB 00:00 ansible-server: (4/12): python3-ply-3.11-14.el9.0.1.noarch.rpm 211 kB/s | 103 kB 00:00 ansible-server: (5/12): python3-pycparser-2.20-6.el9.noarch.rpm 1.1 MB/s | 124 kB 00:00 ansible-server: (6/12): python3-packaging-20.9-5.el9.noarch.rpm 1.4 MB/s | 69 kB 00:00 ansible-server: (7/12): python3-resolvelib-0.5.4-5.el9.noarch.r 1.8 MB/s | 29 kB 00:00 ansible-server: (8/12): sshpass-1.09-4.el9.x86_64.rpm 1.5 MB/s | 27 kB 00:00 ansible-server: (9/12): git-core-2.39.3-1.el9_2.x86_64.rpm 40 MB/s | 4.2 MB 00:00 ansible-server: (10/12): ansible-core-2.14.9-1.el9.x86_64.rpm 33 MB/s | 2.2 MB 00:00 ansible-server: (11/12): python3-cryptography-36.0.1-4.el9.x86_ 1.1 MB/s | 1.2 MB 00:01 ansible-server: (12/12): ansible-7.7.0-1.el9.noarch.rpm 24 MB/s | 34 MB 00:01 ansible-server: -------------------------------------------------------------------------------- ansible-server: Total 13 MB/s | 43 MB 00:03 ansible-server: Extra Packages for Enterprise Linux 9 - x86_64 1.6 MB/s | 1.6 kB 00:00 ansible-server: Importing GPG key 0x3228467C: ansible-server: Userid : "Fedora (epel9) " ansible-server: Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C ansible-server: From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9 ansible-server: Key imported successfully ansible-server: Running transaction check ansible-server: Transaction check succeeded. ansible-server: Running transaction test ansible-server: Transaction test succeeded. ansible-server: Running transaction ansible-server: Preparing : 1/1 ansible-server: Installing : git-core-2.39.3-1.el9_2.x86_64 1/12 ansible-server: Installing : sshpass-1.09-4.el9.x86_64 2/12 ansible-server: Installing : python3-resolvelib-0.5.4-5.el9.noarch 3/12 ansible-server: Installing : python3-ply-3.11-14.el9.0.1.noarch 4/12 ansible-server: Installing : python3-pycparser-2.20-6.el9.noarch 5/12 ansible-server: Installing : python3-cffi-1.14.5-5.el9.x86_64 6/12 ansible-server: Installing : python3-cryptography-36.0.1-4.el9.x86_64 7/12 ansible-server: Installing : python3-setuptools-53.0.0-12.el9.noarch 8/12 ansible-server: Installing : python3-pyparsing-2.4.7-9.el9.noarch 9/12 ansible-server: Installing : python3-packaging-20.9-5.el9.noarch 10/12 ansible-server: Installing : ansible-core-1:2.14.9-1.el9.x86_64 11/12 ansible-server: Installing : ansible-1:7.7.0-1.el9.noarch 12/12 ansible-server: Running scriptlet: ansible-1:7.7.0-1.el9.noarch 12/12 ansible-server: Verifying : ansible-1:7.7.0-1.el9.noarch 1/12 ansible-server: Verifying : python3-pyparsing-2.4.7-9.el9.noarch 2/12 ansible-server: Verifying : python3-setuptools-53.0.0-12.el9.noarch 3/12 ansible-server: Verifying : python3-cryptography-36.0.1-4.el9.x86_64 4/12 ansible-server: Verifying : python3-cffi-1.14.5-5.el9.x86_64 5/12 ansible-server: Verifying : python3-ply-3.11-14.el9.0.1.noarch 6/12 ansible-server: Verifying : python3-pycparser-2.20-6.el9.noarch 7/12 ansible-server: Verifying : python3-packaging-20.9-5.el9.noarch 8/12 ansible-server: Verifying : python3-resolvelib-0.5.4-5.el9.noarch 9/12 ansible-server: Verifying : sshpass-1.09-4.el9.x86_64 10/12 ansible-server: Verifying : git-core-2.39.3-1.el9_2.x86_64 11/12 ansible-server: Verifying : ansible-core-1:2.14.9-1.el9.x86_64 12/12 ansible-server: ansible-server: Installed: ansible-server: ansible-1:7.7.0-1.el9.noarch ansible-server: ansible-core-1:2.14.9-1.el9.x86_64 ansible-server: git-core-2.39.3-1.el9_2.x86_64 ansible-server: python3-cffi-1.14.5-5.el9.x86_64 ansible-server: python3-cryptography-36.0.1-4.el9.x86_64 ansible-server: python3-packaging-20.9-5.el9.noarch ansible-server: python3-ply-3.11-14.el9.0.1.noarch ansible-server: python3-pycparser-2.20-6.el9.noarch ansible-server: python3-pyparsing-2.4.7-9.el9.noarch ansible-server: python3-resolvelib-0.5.4-5.el9.noarch ansible-server: python3-setuptools-53.0.0-12.el9.noarch ansible-server: sshpass-1.09-4.el9.x86_64 ansible-server: ansible-server: Complete! ansible-server: Last metadata expiration check: 0:00:20 ago on Thu 28 Mar 2024 05:44:58 AM UTC. ansible-server: Dependencies resolved. ansible-server: ================================================================================ ansible-server: Package Architecture Version Repository Size ansible-server: ================================================================================ ansible-server: Installing: ansible-server: net-tools x86_64 2.0-0.62.20160912git.el9 baseos 292 k ansible-server: ansible-server: Transaction Summary ansible-server: ================================================================================ ansible-server: Install 1 Package ansible-server: ansible-server: Total download size: 292 k ansible-server: Installed size: 912 k ansible-server: Downloading Packages: ansible-server: net-tools-2.0-0.62.20160912git.el9.x86_64.rpm 5.3 MB/s | 292 kB 00:00 ansible-server: -------------------------------------------------------------------------------- ansible-server: Total 421 kB/s | 292 kB 00:00 ansible-server: Running transaction check ansible-server: Transaction check succeeded. ansible-server: Running transaction test ansible-server: Transaction test succeeded. ansible-server: Running transaction ansible-server: Preparing : 1/1 ansible-server: Installing : net-tools-2.0-0.62.20160912git.el9.x86_64 1/1 ansible-server: Running scriptlet: net-tools-2.0-0.62.20160912git.el9.x86_64 1/1 ansible-server: Verifying : net-tools-2.0-0.62.20160912git.el9.x86_64 1/1 ansible-server: ansible-server: Installed: ansible-server: net-tools-2.0-0.62.20160912git.el9.x86_64 ansible-server: ansible-server: Complete! ==> ansible-server: Running provisioner: file... ansible-server: ansible_env_ready.yml => ansible_env_ready.yml ==> ansible-server: Running provisioner: shell... ansible-server: Running: inline script ansible-server: [WARNING]: provided hosts list is empty, only localhost is available. Note that ansible-server: the implicit localhost does not match 'all' ansible-server: ansible-server: PLAY [Setup for the Ansible's Environment] ************************************* ansible-server: ansible-server: TASK [Add "/etc/ansible/hosts"] ************************************************ ansible-server: changed: [localhost] ansible-server: ansible-server: TASK [Install sshpass for Authentication] ************************************** ansible-server: ok: [localhost] ansible-server: ansible-server: TASK [Create vim env's directories & files] ************************************ ansible-server: changed: [localhost] => (item=mkdir -p /home/vagrant/.vim/autoload /home/vagrant/.vim/bundle) ansible-server: changed: [localhost] => (item=touch /home/vagrant/.vimrc) ansible-server: changed: [localhost] => (item=touch /home/vagrant/.bashrc) ansible-server: ansible-server: TASK [Install vim-enhanced] **************************************************** ansible-server: changed: [localhost] ansible-server: ansible-server: TASK [Install git] ************************************************************* ansible-server: changed: [localhost] ansible-server: ansible-server: TASK [Download pathogen.vim] *************************************************** ansible-server: changed: [localhost] ansible-server: ansible-server: TASK [Git clone vim-ansible-yaml] ********************************************** ansible-server: changed: [localhost] ansible-server: ansible-server: TASK [Configure vimrc] ********************************************************* ansible-server: changed: [localhost] => (item=set number) ansible-server: changed: [localhost] => (item=execute pathogen#infect()) ansible-server: changed: [localhost] => (item=syntax on) ansible-server: ansible-server: TASK [Configure Bashrc] ******************************************************** ansible-server: changed: [localhost] => (item=alias ans='ansible') ansible-server: changed: [localhost] => (item=alias anp='ansible-playbook') ansible-server: ansible-server: PLAY RECAP ********************************************************************* ansible-server: localhost : ok=9 changed=8 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 ansible-server: ==> ansible-server: Running provisioner: shell... ansible-server: Running: C:/Users/user2/AppData/Local/Temp/vagrant-shell20240328-4556-pakm53.sh ansible-server: Warning: Permanently added '200.200.200.147' (ED25519) to the list of known hosts. ansible-server: Warning: Permanently added '200.200.200.148' (ED25519) to the list of known hosts. --test PS D:\vagrant_test> vagrant ssh ansible-server [vagrant@ansible-server ~]$ ansible all -m ping -k SSH password: 200.200.200.148 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } 200.200.200.147 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" }