安利:鲲鹏920CentOS7部署ansible

Posted 闭关苦炼内功

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安利:鲲鹏920CentOS7部署ansible相关的知识,希望对你有一定的参考价值。



ansible是个啥?
安利:鲲鹏920CentOS7部署ansible_运维
在鲲鹏920架构CentOS7上,也可以部署ansible,一起来玩哈!




文章目录


ansible官方文档地址

​​

​​​​

ansible官方下载地址

​​

​​​​

0、查看系统信息

编写查看系统信息脚本

​vim sysinfo.sh​

#!/bin/bash
uname -a && echo && \\
cat /etc/centos-release && echo && \\
hostnamectl && echo && \\
lscpu && echo && \\
free -h && echo && \\
lsblk && echo && \\
df -hT

授权可执行权限

​chmod u+x sysinfo.sh​

执行脚本

​./sysinfo.sh​

[root@localhost ~]# ./sysinfo.sh
Linux localhost 4.18.0-80.7.2.el7.aarch64 #1 SMP Thu Sep 12 16:13:20 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

CentOS Linux release 7.7.1908 (AltArch)

Static hostname: localhost
Icon name: computer-vm
Chassis: vm
Machine ID: 9366bdcf7344482682f1eafbe02d2e0e
Boot ID: 3276823f5fee4941869af296dedddf98
Virtualization: kvm
Operating System: CentOS Linux 7 (AltArch)
CPE OS Name: cpe:/o:centos:centos:7:server
Kernel: Linux 4.18.0-80.7.2.el7.aarch64
Architecture: arm64

Architecture: aarch64
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 8
Socket(s): 1
NUMA node(s): 1
Model: 0
BogoMIPS: 200.00
NUMA node0 CPU(s): 0-7
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma dcpop asimddp

total used free shared buff/cache available
Mem: 15G 371M 15G 26M 436M 14G
Swap: 0B 0B 0B

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdd 8:48 0 500G 0 disk
sdb 8:16 0 500G 0 disk
sdc 8:32 0 500G 0 disk
sda 8:0 0 500G 0 disk
©À©¤sda2 8:2 0 79.8G 0 part /
©¸©¤sda1 8:1 0 200M 0 part /boot/efi

Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 8.0G 0 8.0G 0% /dev
tmpfs tmpfs 8.0G 0 8.0G 0% /dev/shm
tmpfs tmpfs 8.0G 27M 8.0G 1% /run
tmpfs tmpfs 8.0G 0 8.0G 0% /sys/fs/cgroup
/dev/sda2 ext4 79G 4.4G 71G 6% /
/dev/sda1 vfat 200M 4.5M 196M 3% /boot/efi
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
[root@localhost ~]#

1、安装epel

​yum install epel-release -y​

2、安装ansible

  • 查看是否支持ansible
    ​​​yum search ansible​
[root@localhost ~]# yum search ansible
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/aarch64/metalink | 9.9 kB 00:00:00
* base: mirrors.huaweicloud.com
* epel: epel.01link.hk
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
epel | 5.4 kB 00:00:00
(1/3): epel/aarch64/group_gz | 88 kB 00:00:00
(2/3): epel/aarch64/updateinfo | 1.0 MB 00:00:00
(3/3): epel/aarch64/primary_db | 6.6 MB 00:00:00
================================================================================= N/S matched: ansible ==================================================================================
ansible-doc.noarch : Documentation for Ansible
ansible-inventory-grapher.noarch : Creates graphs representing ansible inventory
ansible-lint.noarch : Best practices checker for Ansible
ansible-openstack-modules.noarch : Unofficial Ansible modules for managing Openstack
ansible-review.noarch : Reviews Ansible playbooks, roles and inventory and suggests improvements
centos-release-ansible-27.noarch : Ansible 2.7 packages from the CentOS ConfigManagement SIG repository
centos-release-ansible-28.noarch : Ansible 2.8 packages from the CentOS ConfigManagement SIG repository
centos-release-ansible-29.noarch : Ansible 2.9 packages from the CentOS ConfigManagement SIG repository
python2-ansible-runner.noarch : A tool and python library to interface with Ansible
python2-ansible-tower-cli.noarch : A CLI tool for Ansible Tower
ansible.noarch : SSH-based configuration management, deployment, and task execution system
kubernetes-ansible.noarch : Playbook and set of roles for seting up a Kubernetes cluster onto machines
loopabull.noarch : Event loop driven Ansible playbook execution engine
standard-test-roles.noarch : Standard Test Interface Ansible roles

Name and summary matches only, use "search all" for everything.
[root@localhost ~]#
  • 安装ansible
    ​​​yum -y install ansible​

3、查看安装版本

​ansible --version​

[root@localhost ~]# ansible --version
ansible 2.8.5
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 = /usr/bin/ansible
python version = 2.7.5 (default, Aug 7 2019, 00:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[root@localhost ~]#

4、查看ansible默认安装目录

[root@localhost ~]# ll /etc/ansible/
total 28
-rw-r--r-- 1 root root 19980 Sep 14 2019 ansible.cfg
-rw-r--r-- 1 root root 1016 Sep 14 2019 hosts
drwxr-xr-x 2 root root 4096 Sep 14 2019 roles

​ansible.cfg​ 是ansible配置文件

​hosts​ 是管理端主机IP

​roles​ 是规则

[root@localhost ~]# cd /etc/ansible/
[root@localhost ansible]#
[root@localhost ansible]# vim hosts
[root@localhost ansible]#
[root@localhost ansible]# vim ansible.cfg

5、测试一下ansible是否能够使用

注意细节:

这个时候不能再root用户下执行下面的命令,需要切换到普通用户下去执行

[coding@localhost ~]$ ​​ansible all -m ping​

[coding@localhost ~]$ ​​ansible all -m command -a "free -h"​

[coding@localhost ~]$ ​​ansible all -m command -a "iostat"​

[coding@localhost ~]$ ​​ansible all -m command -a "cat /etc/centos-release"​


下期预告:在鲲鹏架构openEuler上部署ansible

敬请期待!

都看到最后啦,点个赞支持一下再走呗!



以上是关于安利:鲲鹏920CentOS7部署ansible的主要内容,如果未能解决你的问题,请参考以下文章

安利:华为鲲鹏920云主机部署Nginx服务器一键拉起自动化脚本

安利:华为鲲鹏920云主机磁盘扩容脚本

华为鲲鹏920云主机部署zookeeper集群(3.6.3版本)

华为鲲鹏920云主机部署zookeeper集群(3.6.3版本)

华为鲲鹏920云主机部署kafka集群(2.2.1版本)

华为鲲鹏920云主机部署kafka集群(2.2.1版本)