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

丹灶网站设计百度网盟推广

丹灶网站设计,百度网盟推广,wordpress 文档主题,wordpress update_post_metaAnsible是Python开发的自动化运维工具,集合了众多运维工具(Puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置,批量程序部署、批量运行命令等功能。 特点: 1)部署简单&#xff…

Ansible是Python开发的自动化运维工具,集合了众多运维工具(Puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置,批量程序部署、批量运行命令等功能。

特点:

1)部署简单;

2)默认使用ssh进行管理,基于Python里的paramiko模块开发;

3)管理端和被管理端不需要启动服务;

4)配置简单、功能强大、拓展性强;

5)能playbook剧本进行多任务的编排;

 

实验准备:

三台机器:一台管理、两台被管理。

主机IP地址备注信息
管理机Master192.168.17.104
被管理机1192.168.17.105
被管理机2192.168.17.106

实验过程:

1)在管理机上安装ansible,被管理机上必须打开ssh服务。

yum install -y epel-release
yum install ansible[root@localhost ~]# ansible --version
ansible 2.9.27config file = /etc/ansible/ansible.cfgconfigured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']ansible python module location = /usr/lib/python2.7/site-packages/ansibleexecutable location = /usr/bin/ansiblepython version = 2.7.5 (default, Jun 20 2023, 11:36:40) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

 2)实现master对agent的免密登录,只有master上做。(如果这步不做的话,则在后面操作agent时候要加上-k参数传密码,或者在主机清单里传密码。)

ssh-keygenssh-copy-id -i 192.168.17.105
ssh-copy-id -i 192.168.17.106

3)在master上定义主机组,并测试连接性。

 说明:inventory:财产清单,库存等。

在hosts清单中添加两个机器IP地址。

[root@localhost ansible]# tail -3 hosts
[group1]
192.168.17.105
192.168.17.106
[root@localhost ansible]# ansible all -m ping
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

说明:all是所有机器。-m是module的意思,ping是模块。

[root@localhost ansible]# ansible group1 -m ping
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

服务器分组:

ansible通过一个主机清单功能来实现服务器分组。

Ansible的默认主机清单配置文件为/etc/ansible/hosts

 另外,如果服务器比较多的情况下,也可以写:

[nginx]
apache[1:10].aaa.com
nginx[a:z].aaa.com
10.1.1.[11:15]
[root@localhost ansible]# tail -2 hosts
[group1]
192.168.17.[105:106]

然后再用ping模块测试:

[root@localhost ansible]# ansible group1 -m ping
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

再看一个例子:

[nginx]
10.1.1.13:2222

表示的是10.1.1.13这台机器,但是端口是2222端口。

[root@localhost ansible]# tail -3 hosts
[group1]
192.168.17.105
192.168.17.106:2222
[root@localhost ansible]# ansible group1 -m ping
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
192.168.17.106 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

别名的写法:

定义10.1.1.12:2222 这台服务器的别名nginx1。

nginx1 ansible_ssh_hosts=10.1.1.13 ansible_ssh_port=2222

没有做免密登录的服务器可以指定用户名和密码

nginx1 ansible_ssh_host=10.1.1.13 ansible_ssh_port=2222 ansible_ssh_user=root ansible_ssh_pass="123456"
nginx2 ansible_ssh_host=10.1.1.12# /etc/ansible/hosts
[nginx]
nginx1
nginx2

说明:密码最好是一个加密字符串。

[root@localhost ansible]# tail -6 hosts
nginx1 ansible_ssh_host=192.168.17.106 ansible_ssh_port=2222 ansible_ssh_user=root ansible_ssh_pass="1q2w3e4r"## db-[99:101]-node.example.com
[group1]
192.168.17.105
nginx1

 别名的测试。

[root@localhost ansible]# ansible group1 -m ping
192.168.17.105 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}
nginx1 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"},"changed": false,"ping": "pong"
}

小结:

主机清单的作用:服务器分组。主机清单就是服务器分组。

主机清单的常见功能:

1)可以通过IP范围来分,主机名的名称来分;

2)如果ssh端口不是22,可以传入新端口;

3)没有做免密登录,可以传密码。

不论是哪种环境(免密或不免密,端口是否22),请最终将两台被管理机器加入到group1组即可。

http://www.yidumall.com/news/30135.html

相关文章:

  • 个人如何做网站软件武汉网站维护公司
  • 企商网站建设百度推广电话客服24小时
  • 公司做网站的目的网络营销步骤
  • 佛山营销手机网站建设南京seo网络推广
  • 淅川做网站企业推广公司
  • 郑州企业网站建站模板app拉新平台有哪些
  • Wordpress福利资源模板亚马逊关键词优化怎么做
  • 新闻网站开发php代码简单的个人主页网站制作
  • 网站制作方案报价优化手机流畅度的软件
  • wordpress文章摘要调用百度seo排名在线点击器
  • 网站运营维护方案2022世界足球排行榜
  • 政府网站建设排版产品经理培训哪个机构好
  • 腾讯 云上做网站教程免费发软文的网站
  • 域名出售后被用来做非法网站百度热门搜索排行榜
  • 重庆做商城网站建设关键路径
  • 建站平台做的网站google线上平台推广方式
  • 邵阳 做网站公司2023全民核酸又开始了
  • 网站建设 知识库百度推广投诉电话客服24小时
  • 标准网站建设手机百度高级搜索入口在哪里
  • 北京微网站建设软文营销的步骤
  • 珠海网站制作推广公司东莞企业网站排名
  • 弄淘宝招牌图什么网站可以做青岛网络优化厂家
  • 网站开发平台建设短期培训班学什么好
  • 做公司标志用哪个网站个人推广平台
  • 宏福建设集团有限公司网站网络营销做得好的公司
  • 深圳最好的营销网站建设公司魔贝课凡seo
  • 深圳大浪有做网站的吗免费发布产品的平台
  • php网站开发好找工作吗今日军事新闻视频
  • 建设嘉陵摩托车官方网站seo搜索引擎招聘
  • 做网站找图片晚上网站推广软件免费版