当前位置: 首页 > news >正文

网站或站点的第一个网页南京 seo 价格

网站或站点的第一个网页,南京 seo 价格,万网个人网站,便宜的做网站Ansible自动化运维工具 概述安装部署1.通过yum下载Ansible2.对自己做免密配置3.修改ansiable host配置对服务器进行分组4.测试:对所有服务器进行ping命令5.写playbook6.执行我们写的playbook脚本7.验证 概述 ansible是新出现的自动化运维工具,基于Pytho…

Ansible自动化运维工具

  • 概述
  • 安装部署
    • 1.通过yum下载Ansible
    • 2.对自己做免密配置
    • 3.修改ansiable host配置对服务器进行分组
    • 4.测试:对所有服务器进行ping命令
    • 5.写playbook
    • 6.执行我们写的playbook脚本
    • 7.验证

概述

ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。Ansible架构相对比较简单,仅需通过SSH连接客户机执行任务即可。

安装部署

1.通过yum下载Ansible

[root@server1 ~]# yum install -y ansible
Last metadata expiration check: 1:33:20 ago on 2023年11月14日 星期二 19时08分08秒.
Dependencies resolved.
=================================================================================================================================================================================================================================================Package                                                     Architecture                                  Version                                                 Repository                                                               Size
=================================================================================================================================================================================================================================================
Installing:ansible                                                     noarch                                        2.9.11-1.uel20                                          UnionTechOS-Server-20-everything                                         17 M
Installing dependencies:libsodium                                                   x86_64                                        1.0.18-1.uel20                                          UnionTechOS-Server-20-everything                                        152 kpython3-asn1crypto                                          noarch                                        1.4.0-1.uel20                                           UnionTechOS-Server-20-everything                                        181 kpython3-babel                                               noarch                                        2.8.0-3.uel20                                           UnionTechOS-Server-20-everything                                        6.1 Mpython3-bcrypt                                              x86_64                                        3.2.0-1.uel20                                           UnionTechOS-Server-20-everything                                         40 kpython3-cffi                                                x86_64                                        1.14.1-1.uel20                                          UnionTechOS-Server-20-everything                                        236 kpython3-cryptography                                        x86_64                                        3.3.1-1.uel20                                           UnionTechOS-Server-20-everything                                        402 kpython3-invoke                                              noarch                                        1.5.0-1.uel20.01                                        UnionTechOS-Server-20-everything                                        267 kpython3-jinja2                                              noarch                                        2.11.2-2.uel20                                          UnionTechOS-Server-20-everything                                        223 kpython3-jmespath                                            noarch                                        0.9.0-11.uel20                                          UnionTechOS-Server-20-everything                                         42 kpython3-markupsafe                                          x86_64                                        1.1.1-1.uel20                                           UnionTechOS-Server-20-everything                                         28 kpython3-pyasn1                                              noarch                                        0.4.8-1.uel20                                           UnionTechOS-Server-20-everything                                        136 kpython3-pycparser                                           noarch                                        2.20-2.uel20                                            UnionTechOS-Server-20-everything                                        155 kpython3-pynacl                                              x86_64                                        1.2.1-5.uel20                                           UnionTechOS-Server-20-everything                                         76 kpython3-pyyaml                                              x86_64                                        5.3.1-4.uel20                                           UnionTechOS-Server-20-everything                                        188 ksshpass                                                     x86_64                                        1.06-8.uel20                                            UnionTechOS-Server-20-everything                                         24 k
Installing weak dependencies:python3-paramiko                                            noarch                                        2.7.2-2.uel20                                           UnionTechOS-Server-20-everything                                        289 kTransaction Summary
=================================================================================================================================================================================================================================================
Install  17 PackagesTotal download size: 26 M
Installed size: 135 M
Downloading Packages:
(1/17): libsodium-1.0.18-1.uel20.x86_64.rpm                                                                                                                                                                      177 kB/s | 152 kB     00:00    
(2/17): python3-asn1crypto-1.4.0-1.uel20.noarch.rpm                                                                                                                                                              108 kB/s | 181 kB     00:01    
(3/17): python3-bcrypt-3.2.0-1.uel20.x86_64.rpm                                                                                                                                                                  8.1 kB/s |  40 kB     00:04    
(4/17): python3-cffi-1.14.1-1.uel20.x86_64.rpm                                                                                                                                                                    25 kB/s | 236 kB     00:09    
(5/17): python3-cryptography-3.3.1-1.uel20.x86_64.rpm                                                                                                                                                             31 kB/s | 402 kB     00:12    
(6/17): python3-invoke-1.5.0-1.uel20.01.noarch.rpm                                                                                                                                                                31 kB/s | 267 kB     00:08    
(7/17): python3-jinja2-2.11.2-2.uel20.noarch.rpm                                                                                                                                                                  22 kB/s | 223 kB     00:10    
(8/17): python3-jmespath-0.9.0-11.uel20.noarch.rpm                                                                                                                                                                10 kB/s |  42 kB     00:04    
(9/17): python3-markupsafe-1.1.1-1.uel20.x86_64.rpm                                                                                                                                                              4.4 kB/s |  28 kB     00:06    
(10/17): python3-paramiko-2.7.2-2.uel20.noarch.rpm                                                                                                                                                                25 kB/s | 289 kB     00:11    
(11/17): python3-pyasn1-0.4.8-1.uel20.noarch.rpm                                                                                                                                                                  17 kB/s | 136 kB     00:07    
(12/17): python3-pycparser-2.20-2.uel20.noarch.rpm                                                                                                                                                                28 kB/s | 155 kB     00:05    
(13/17): python3-pynacl-1.2.1-5.uel20.x86_64.rpm                                                                                                                                                                  13 kB/s |  76 kB     00:05    
(14/17): python3-pyyaml-5.3.1-4.uel20.x86_64.rpm                                                                                                                                                                  31 kB/s | 188 kB     00:06    
(15/17): sshpass-1.06-8.uel20.x86_64.rpm                                                                                                                                                                         5.3 kB/s |  24 kB     00:04    
(16/17): python3-babel-2.8.0-3.uel20.noarch.rpm                                                                                                                                                                   35 kB/s | 6.1 MB     02:58    
(17/17): ansible-2.9.11-1.uel20.noarch.rpm                                                                                                                                                                        87 kB/s |  17 MB     03:22    
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                            130 kB/s |  26 MB     03:22     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing        :                                                                                                                                                                                                                         1/1 Installing       : python3-jmespath-0.9.0-11.uel20.noarch                                                                                                                                                                                 1/17 Installing       : sshpass-1.06-8.uel20.x86_64                                                                                                                                                                                            2/17 Installing       : python3-pyyaml-5.3.1-4.uel20.x86_64                                                                                                                                                                                    3/17 Installing       : python3-pycparser-2.20-2.uel20.noarch                                                                                                                                                                                  4/17 Installing       : python3-cffi-1.14.1-1.uel20.x86_64                                                                                                                                                                                     5/17 Installing       : python3-bcrypt-3.2.0-1.uel20.x86_64                                                                                                                                                                                    6/17 Installing       : python3-pyasn1-0.4.8-1.uel20.noarch                                                                                                                                                                                    7/17 Installing       : python3-markupsafe-1.1.1-1.uel20.x86_64                                                                                                                                                                                8/17 Installing       : python3-invoke-1.5.0-1.uel20.01.noarch                                                                                                                                                                                 9/17 Installing       : python3-babel-2.8.0-3.uel20.noarch                                                                                                                                                                                    10/17 Installing       : python3-jinja2-2.11.2-2.uel20.noarch                                                                                                                                                                                  11/17 Installing       : python3-asn1crypto-1.4.0-1.uel20.noarch                                                                                                                                                                               12/17 Installing       : python3-cryptography-3.3.1-1.uel20.x86_64                                                                                                                                                                             13/17 Installing       : libsodium-1.0.18-1.uel20.x86_64                                                                                                                                                                                       14/17 Installing       : python3-pynacl-1.2.1-5.uel20.x86_64                                                                                                                                                                                   15/17 Installing       : python3-paramiko-2.7.2-2.uel20.noarch                                                                                                                                                                                 16/17 Installing       : ansible-2.9.11-1.uel20.noarch                                                                                                                                                                                         17/17 Running scriptlet: ansible-2.9.11-1.uel20.noarch                                                                                                                                                                                         17/17 Verifying        : ansible-2.9.11-1.uel20.noarch                                                                                                                                                                                          1/17 Verifying        : libsodium-1.0.18-1.uel20.x86_64                                                                                                                                                                                        2/17 Verifying        : python3-asn1crypto-1.4.0-1.uel20.noarch                                                                                                                                                                                3/17 Verifying        : python3-babel-2.8.0-3.uel20.noarch                                                                                                                                                                                     4/17 Verifying        : python3-bcrypt-3.2.0-1.uel20.x86_64                                                                                                                                                                                    5/17 Verifying        : python3-cffi-1.14.1-1.uel20.x86_64                                                                                                                                                                                     6/17 Verifying        : python3-cryptography-3.3.1-1.uel20.x86_64                                                                                                                                                                              7/17 Verifying        : python3-invoke-1.5.0-1.uel20.01.noarch                                                                                                                                                                                 8/17 Verifying        : python3-jinja2-2.11.2-2.uel20.noarch                                                                                                                                                                                   9/17 Verifying        : python3-jmespath-0.9.0-11.uel20.noarch                                                                                                                                                                                10/17 Verifying        : python3-markupsafe-1.1.1-1.uel20.x86_64                                                                                                                                                                               11/17 Verifying        : python3-paramiko-2.7.2-2.uel20.noarch                                                                                                                                                                                 12/17 Verifying        : python3-pyasn1-0.4.8-1.uel20.noarch                                                                                                                                                                                   13/17 Verifying        : python3-pycparser-2.20-2.uel20.noarch                                                                                                                                                                                 14/17 Verifying        : python3-pynacl-1.2.1-5.uel20.x86_64                                                                                                                                                                                   15/17 Verifying        : python3-pyyaml-5.3.1-4.uel20.x86_64                                                                                                                                                                                   16/17 Verifying        : sshpass-1.06-8.uel20.x86_64                                                                                                                                                                                           17/17 Installed:ansible-2.9.11-1.uel20.noarch             libsodium-1.0.18-1.uel20.x86_64        python3-asn1crypto-1.4.0-1.uel20.noarch python3-babel-2.8.0-3.uel20.noarch     python3-bcrypt-3.2.0-1.uel20.x86_64     python3-cffi-1.14.1-1.uel20.x86_64   python3-cryptography-3.3.1-1.uel20.x86_64 python3-invoke-1.5.0-1.uel20.01.noarch python3-jinja2-2.11.2-2.uel20.noarch    python3-jmespath-0.9.0-11.uel20.noarch python3-markupsafe-1.1.1-1.uel20.x86_64 python3-paramiko-2.7.2-2.uel20.noarchpython3-pyasn1-0.4.8-1.uel20.noarch       python3-pycparser-2.20-2.uel20.noarch  python3-pynacl-1.2.1-5.uel20.x86_64     python3-pyyaml-5.3.1-4.uel20.x86_64    sshpass-1.06-8.uel20.x86_64            Complete!
[root@server1 ~]# 

2.对自己做免密配置

之前已生成密钥 对这一块不了解的请查看 【LIUNX】机器互访:免密登陆

[root@server1 ~]# ssh-copy-id root@server1
/usr/bin/ssh-copy-id: INFO: Source of  key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'server1 (192.168.122.1)' can't be established.
ECDSA key fingerprint is SHA256:TWajqYQ0cY7n48NQANig8R2qvjcRIDQagMvYot7yIT4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
UnionTech OS Server 20 1050e
root@server1's password: Number of key(s) added: 1Now try logging into the machine, with:   "ssh 'root@server1'"
and check to make sure that only the key(s) you wanted were added.
[root@server1 ~]# ssh root@server1
UnionTech OS Server 20 1050eAuthorized users only. All activities may be monitored and reported.
Last login: Tue Nov 14 15:18:38 2023 from 192.168.3.1Welcome to 4.19.90-2201.4.0.0135.up1.uel20.x86_64System information as of time: 		20231114日 星期二 20:53:43 CSTSystem load: 		0.01
Processes: 		202
Memory used: 		58.1%
Swap used: 		0.2%
Usage On: 		10%
IP address: 		192.168.3.5
IP address: 		192.168.122.1
IP address: 		172.17.0.1
Users online: 		3[root@server1 ~]# exit
注销
Connection to server1 closed.
[root@server1 ~]# ssh root@server2
UnionTech OS Server 20 1050eAuthorized users only. All activities may be monitored and reported.
Last login: Tue Nov 14 15:18:29 2023 from 192.168.122.1Welcome to 4.19.90-2201.4.0.0135.up1.uel20.x86_64System information as of time: 		20231114日 星期二 20:53:41 CSTSystem load: 		0.00
Processes: 		121
Memory used: 		13.2%
Swap used: 		0.0%
Usage On: 		6%
IP address: 		192.168.122.2
Users online: 		2

免密已经成功了

3.修改ansiable host配置对服务器进行分组

  • 在/etc/ansible/hosts最下方新增一下组别和服务器名

[web]
server1
[db]
server2

结果如下

[root@server1 ~]# vi /etc/ansible/hosts 
[root@server1 ~]# cat /etc/ansible/hosts 
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#   - Comments begin with the '#' character
#   - Blank lines are ignored
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups# Ex 1: Ungrouped hosts, specify before any group headers.## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10# Ex 2: A collection of hosts belonging to the 'webservers' group## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110# If you have multiple hosts following a pattern you can specify
# them like this:## www[001:006].example.com# Ex 3: A collection of database servers in the 'dbservers' group## [dbservers]
## 
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57# Here's another example of host ranges, this time there are no
# leading 0s:## db-[99:101]-node.example.com
[web]
server1
[db]
server2

4.测试:对所有服务器进行ping命令

root@server1 ~]# ansible all -m ping
[WARNING]: Platform linux on host server2 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
server2 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
[WARNING]: Platform linux on host server1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
server1 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

5.写playbook

vi install_php_fpm.yml

内容如下:

---
- hosts: webuser: roottasks: - name: install php-fpmyum: name: php-fpmstate: present- name: start php-fpmservice: name: php-fpmstate: startedenable: yes

注意:yml文件每行的前面不能用tab只能使用空格

[root@server1 ~]# vi install_php_fpm.yml
[root@server1 ~]# cat install_php_fpm.yml 
---
- hosts: webtasks:- name: install phpyum:name: "{{item}}"state: presentloop:- php-fpm- samba- name: start phpservice:name: php-fpmstate: startedenabled: yes- name: start smbservice:name: smbstate: startedenabled: yes
- hosts: dbtasks:- name: install mariadbyum:name: mariadb-serverstate: present- name: start mariadbservice:name: mariadbstate: startedenabled: yes
[root@server1 ~]# ansible-playbook --syntax-check install_php_fpm.yml playbook: install_php_fpm.yml

ansible-playbook --syntax-check验证脚本是否正确
命令格式如下:
ansible-playbook --syntax-check xxx.yml

6.执行我们写的playbook脚本

[root@server1 ~]#  ansible-playbook install_php_fpm.yml -e "ansible_python_interpreter=/usr/bin/python3"PLAY [web] **************************************************************************************************************************************************************************************************************************************TASK [Gathering Facts] **************************************************************************************************************************************************************************************************************************
ok: [server1]TASK [install php] ******************************************************************************************************************************************************************************************************************************
ok: [server1] => (item=php-fpm)
changed: [server1] => (item=samba)TASK [start php] ********************************************************************************************************************************************************************************************************************************
ok: [server1]TASK [start smb] ********************************************************************************************************************************************************************************************************************************
changed: [server1]PLAY [db] ***************************************************************************************************************************************************************************************************************************************TASK [Gathering Facts] **************************************************************************************************************************************************************************************************************************
ok: [server2]TASK [install mariadb] **************************************************************************************************************************************************************************************************************************
changed: [server2]TASK [start mariadb] ****************************************************************************************************************************************************************************************************************************
changed: [server2]PLAY RECAP **************************************************************************************************************************************************************************************************************************************
server1                    : ok=4    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
server2                    : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   [root@server1 ~]# 

命令格式如下:
ansible-playbook xxx.yml

7.验证

[root@server1 ~]# rpm -qc php-fpm
/etc/httpd/conf.d/php.conf
/etc/logrotate.d/php-fpm
/etc/nginx/conf.d/php-fpm.conf
/etc/nginx/default.d/php.conf
/etc/php-fpm.conf
/etc/php-fpm.d/www.conf
[root@server1 ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process ManagerLoaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)Active: active (running) since Wed 2023-11-15 00:14:45 CST; 4min 33s agoMain PID: 22863 (php-fpm)Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"Tasks: 6Memory: 16.1MCGroup: /system.slice/php-fpm.service├─22863 php-fpm: master process (/etc/php-fpm.conf)├─22864 php-fpm: pool www├─22865 php-fpm: pool www├─22866 php-fpm: pool www├─22867 php-fpm: pool www└─22868 php-fpm: pool www1115 00:14:45 server1 systemd[1]: Starting The PHP FastCGI Process Manager...
1115 00:14:45 server1 systemd[1]: Started The PHP FastCGI Process Manager.
[root@server1 ~]# 
http://www.yidumall.com/news/48653.html

相关文章:

  • 做古玩生意哪些网站好开源cms建站系统
  • WordPress主题改为html模板搜索引擎优化面对哪些困境
  • 安阳网站建设哪家专业刷评论网站推广
  • 网站建设经营范围国外免费建站网站
  • 公司网站二维码怎么做哪里有永久免费建站
  • 苏州市建设局招标网站百度快照优化排名推广怎么做
  • 合肥做淘宝网站建设最新足球消息
  • 定兴网站建设长春关键词优化报价
  • 影视传媒网站源码seo包年服务
  • 昆明网站搭建百度资源站长平台
  • 国外做蒸汽锅炉的网站推广代理公司
  • 易动力建设网站怎么样站长之家素材
  • 廊坊网站排名优化公司哪家好上海网络推广团队
  • zencart网站管理目前主流搜索引擎是哪种
  • 石家庄做网站公司全媒体运营师报名入口
  • 柳州公积金网站深圳网络推广网站推广
  • 大兴网站建设优化seoseo课程培训中心
  • 微信公众号做公司网站今日最新国内新闻
  • 个体可以做企业网站吗营销策略都有哪些方面
  • 濮阳建站公司流程优化网站seo
  • 做电影网站 广告收入网络营销推广的
  • 网站建设支付国内新闻摘抄2022年
  • 股票网站排名哪个好良品铺子网络营销策划书
  • 做网站不知道做什么内容的长春网站制作企业
  • 传奇网页游戏变态版seoul national university
  • 网站开发设计师广州网站到首页排名
  • 建设公司和建筑公司有什么区别搜索引擎优化是做什么
  • 淘宝店可以做团购的网站sem竞价专员
  • 郑州做网站公司有多少钱百度快速排名系统查询
  • 如何在360网站网页上做笔记安徽网络建站