1、Centos7.9(最小方式安装)
2、修改配置
[root@vm12 ~]# cat /etc/selinux/config | grep -i selinux=
# SELINUX= can take one of these three values:
SELINUX=disabled
修改后重启
否则会出现如下报错
TASK [local_docker : Create Docker Compose Configuration] **********************^M
^[[0;31mfailed: [localhost] (item={u'mode': u'0600', u'file': u'environment.sh'}) => {"ansib
le_loop_var": "item", "changed": false, "checksum": "18957af76126a0769a3d66e4e5a62ff17144eed
2", "item": {"file": "environment.sh", "mode": "0600"}, "msg": "Aborting, target uses selinu
x but python bindings (libselinux-python) aren't installed!"}
3、新建inner79.repo配置文件
[root@vm12 ~]# cat /etc/yum.repos.d/
cat: /etc/yum.repos.d/: Is a directory
[root@vm12 ~]# cd /etc/yum.repos.d/
[root@vm12 yum.repos.d]# ll
total 56
-rw-r--r--. 1 root root 1664 Oct 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Oct 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Oct 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Oct 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Oct 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Oct 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Oct 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 Oct 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 2081 May 16 13:16 docker-ce.repo
-rw-r--r--. 1 root root 951 Oct 3 2017 epel.repo
-rw-r--r--. 1 root root 1050 Oct 3 2017 epel-testing.repo
-rw-r--r--. 1 root root 72 May 16 13:15 inner79.repo
[root@vm12 yum.repos.d]# cat inner79.repo
[inner]
name=inner
baseurl=http://yum.xxxx.xxxx.cn/centos7_9
gpgcheck=0
4、yum初始化
[root@vm12 yum.repos.d]# yum clean; yum makecache
Loaded plugins: fastestmirror
Error: clean requires an option: headers, packages, metadata, dbcache, plugins, expire-cache
, rpmdb, all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
......
Metadata Cache Created
5、安装必要模块wget
[root@vm12 yum.repos.d]# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================
Package Arch Version Repository Size
===========================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 base 547 k
Transaction Summary
===========================================================================
Install 1 Package
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RS
A/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for wget-1.14-18.el7_6.1.x86_64.rpm is not installed
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-9.2009.0.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_6 [#### ] 1/1
Installing : wget-1.14-18.el7_6.1.x86_6 [######### ] 1/1
Installing : wget-1.14-18.el7_6.1.x86_6 [############# ] 1/1
Installing : wget-1.14-18.el7_6.1.x86_6 [################## ] 1/1
Installing : wget-1.14-18.el7_6.1.x86_6 [####################### ] 1/1
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1
Installed:
wget.x86_64 0:1.14-18.el7_6.1
Complete!
6、安装必要模快unzip
yum -y install unzip
7、安装epel-release
yum -y install epel-release
8、安装Ansible
yum -y install ansible
#环境初始化,关闭firewalld与selinux
systemctl disable firewalld
getenforce
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
reboot
#安装所需包,安装docker环境,安装ansible
#导入docker-compose工具,导入镜像
cd /soft
tar zxvf package.tar.gz && cd package
mv docker-compose /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
docker-compose -v
yum -y localinstall ./rpm/*rpm
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://8rl0ig6e.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl enable docker
systemctl restart docker
for i in `ls *tar `;do docker load -i $i;done
for i in `ls *tar `;do docker load -i $i;done
for i in `ls *tar `;do docker load -i $i;done
#安装python3docker-compose库
pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install wheel -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install setuptools_rust -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install --upgrade setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple
#安装ansible-AWX
unzip -q 17.0.0.zip && cd awx-17.0.0/installer
sed s@#project_data_dir=/var/lib/awx/projects@project_data_dir=/var/lib/awx/projects@g inventory -i
sed -i s/'# admin_password=password'/admin_password=admin/ inventory
ansible-playbook -i inventory install.yml