搭建Ansible實驗環境

zchbaby2000發表於2021-03-12

#### 下載並安裝 VirtualBox

#### 下載 CentOS 7
 


建立一個centos-template
clone ansible-controller
clone ansible-target1
clone ansible-target2


(1)
#### 修改host name
sudo vi /etc/hostname
sudo vi /etc/hosts
shutdown now -r
(2)
#### ansiblecontroller
[osboxes@ansiblecontroller ~]$ cat /etc/hostname
ansiblecontroller
[osboxes@ansiblecontroller ~]$ cat /etc/hosts
127.0.0.1   localhost ansiblecontroller
::1         localhost ansiblecontroller
[osboxes@ansiblecontroller ~]$
(3)
#### target1
[osboxes@target1 ~]$ cat /etc/hostname
target1
[osboxes@target1 ~]$ cat /etc/hosts
127.0.0.1   localhost target1
::1         localhost target1
[osboxes@target1 ~]$
(4)
#### target2
[osboxes@target2 ~]$ cat /etc/hostname
target2
[osboxes@target2 ~]$ cat /etc/hosts
127.0.0.1   localhost target2
::1         localhost target2
[osboxes@target2 ~]$
==========================================================
#### 該命表示把Centos-7.repo下載到/etc/yum.repos.d/目錄下,如果該目錄下有CentOS-Base.repo,則會自動覆蓋。
curl -o /etc/yum.repos.d/CentOS-Base.repo

yum clean cache
yum makecache
==========================================================
#### 安裝 epel 源
yum install epel-release -y
#### 安裝依賴工具
yum install git python python-pip -y
==========================================================
#### 設定EPEL倉庫
cd /tmp
wget
#### 使用yum安裝epel
rpm -ivh epel-release-latest-7.noarch.rpm
#### 安裝ansible
yum -y install ansible

[root@ansiblecontroller tmp]# ansible --version
ansible 2.9.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
[root@ansiblecontroller tmp]#

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/725820/viewspace-2762631/,如需轉載,請註明出處,否則將追究法律責任。

相關文章