定义playbook的主机组

说明:

1、playbook的主机组和ansible的主机组不一样,

2、playbook的主机组文件必须要和playbook文件在同一个目录下否则会报如下错误:

[root@test1 profile]# ansible-playbook -i hosts deploy_flanneld.yaml --list-hosts
[WARNING]: Unable to parse /k8s/profile/hosts as an inventory source 3、执行playbook必须要在plyaybook文件所在目录下执行,否则报错;跟带不带绝对路径没有关系,必须保证在同一个目录 4、执行playbook的任何相关操作都要在plyaybook文件所在目录下执行,否则报错;跟带不带绝对路径没有关系,必须保证在同一个目录 cat >/k8s/profile/hosts <<EOF
[webservers]
192.168.0.91
192.168.0.92
EOF playbook文件 cat > /k8s/profile/deploy_nginx.yaml <<EOF
---
- hosts: webservers
become: yes
become_method: sudo
vars:
worker_processes: 4
worker_connections: 768
max_open_files: 65506
tasks:
- name: install nginx
command: yum install nginx -y - name: copy nginx config file
template: src=/home/lmx/test_ansible/nginx.conf.j2 dest=/etc/nginx/nginx.conf
notify: restart nginx - name: copy index.html
template:
src: /home/lmx/test_ansible/index.html.j2
dest: /usr/share/nginx/www/index.html
mode: 0644
notify: restart nginx - name: see file
command: ls /root
notify: restart nginx handlers:
- name: restart nginx
service: name=nginx state=restarted
EOF 模板文件 mkdir -p /home/lmx/test_ansible/ cat > /home/lmx/test_ansible/nginx.conf.j2 << EOF
worker_processes {{ worker_processes }};
worker_rlimit_nofile {{ max_open_files }}; events {
worker_connections {{ worker_connections }};
} http {
server {
listen 80;
root /usr/share/nginx/www;
index index.html index.htm default.html index.php;
server_name loclhost;
location / {
try_files $uri $uri/ =404;
}
} }
EOF cat > /home/lmx/test_ansible/index.html.j2 <<EOF
<html>
<head>
<title>welcome to american</title>
</head>
<body>
<h1>nginx, confitured by ansible</h1>
<p>if you can see this, ansible successfully installed nginx.</p> <p>{{ ansible_hostname }}</p>
</body>
</html>
EOF 开始部署: 说明:必须切换到playbook所在文件目录下执行,否则报错 [root@test1 ~]# cd /k8s/profile/
[root@test1 profile]# ansible-playbook deploy_flanneld.yaml

playbook部署flanneld的更多相关文章

  1. playbook部署coredns

    playbook部署coredns 说明test1是主控节点,目的是给test4 node节点安装coredns, 1.coredns-1.2.2.tar.gz安装包放到主控节点/server/sof ...

  2. 通过PlayBook部署Zabbix

    编写Linux初始化剧本 初始化剧本环节,主要用户实现关闭Selinux关闭防火墙,一起配置一下阿里云的YUM源地址,和安装EPEL源,为后期的zabbix安装做好铺垫工作. 1.在安装Zabbix之 ...

  3. 通过Playbook部署LAMP

    Ansible的PlayBook文件格式为YAML语言,所以希望你在编写PlayBook前对YAML语法有一定的了解,否则在运行PlayBook的时候经常碰到语法错误提示,这里我们通过介绍批量部署LA ...

  4. playbook部署nginx

    定义playbook的主机组 说明: 1.playbook的主机组和ansible的主机组不一样, 2.playbook的主机组文件必须要和playbook文件在同一个目录下否则会报如下错误: [ro ...

  5. ansible playbook部署ELK集群系统

    一.介绍 总共4台机器,分别为 192.168.1.99 192.168.1.100 192.168.1.210 192.168.1.211 服务所在机器为: redis:192.168.1.211 ...

  6. playbook部署mangodb

    playbook文件 [root@localhost ~]# cat deploy_mongo.yaml --- - hosts: webservers become: yes become_meth ...

  7. Ansible playbook 部署filebeat

    - hosts: all tasks: - name: Copy Package copy: src=/usr/local/filebeat--linux-x86_64.tar.gz dest=/us ...

  8. Ansible playbook 部署Openresty

    - hosts: all tasks: - name: copy package copy: src=/usr/local/openresty-1.13.6.1.tar.gz dest=/usr/lo ...

  9. 07-部署Flanneld网络

    部署Flanneld网络 Flanneld:用于解决容器之间网络互通,这里我们要配置TLS认证. Docker1.12.5:docker的安装很简单,这里也不说了. 配置Flanneld 这里我们使用 ...

随机推荐

  1. gitlab 错误处理

    用gitolite新建项目,clone后首次push,可能会出现: $ git push No refs in common and none specified; doing nothing. Pe ...

  2. CVE-2018-10933 LibSSH auth bypass

    漏洞原理 认证实现错误, 认证分为多个步骤,可以直接跳到成功的步骤       A vulnerability was found in libssh's server-side state mach ...

  3. 零基础免费搭建个人博客-hexo+github

    使用hexo生成静态博客并架设在免费的github page平台 准备 系统: Window 7 64位 使用软件: Git v1.9.5[下载地址] 百度云 360云盘 访问密码 d269 Git官 ...

  4. Error creating bean with name 'xxxx' defined in URL

    遇到这种情况,要检查一下以下配置: 1) service接口实现类上有没有加@Service注解,注解是不是引用的spring的类?不要导错包 2) 接口有没有写实现类,实现类是实现的对应接口么?比如 ...

  5. MFC 类内线程函数

    线程函数必须是全局函数或静态成员函数. 非静态成员函数都有一个隐含的参数用于接收所属类的this指针,一般情况下调用时参数不匹配.所以static可以干掉隐含的参数. 但是没有了this,类内的函数就 ...

  6. OFDM留空中央直流子载波目的及原理

    目的: 降低峰均比! 原理: IDFT公式: 直流分量k接近0,公式近似于对X(k)进行累加,因此直流分量会产生较大的信号能量,造成严重的峰均比. 详细内容可参考: https://dwz.cn/Zl ...

  7. Java实现浏览器大文件分片上传

     上周遇到这样一个问题,客户上传高清视频(1G以上)的时候上传失败. 一开始以为是session过期或者文件大小受系统限制,导致的错误. 查看了系统的配置文件没有看到文件大小限制, web.xml中s ...

  8. BZOJ 1195: [HNOI2006]最短母串 AC自动机+状压+搜索

    思路比较直接. 由于 $n$ 很小,直接定义 $f[i][j]$ 表示当前在自动机中的节点 $i,$ 被覆盖串的集合为 $j$ 的方案数. #include <bits/stdc++.h> ...

  9. 在一个非默认的位置包含头文件stdafx.h

    如果stdafx.h和你当前的工程不在一个文件夹下,当你在代码中第一行写下#include "stdafx.h"时,VC编译器会根据编译规则(相关的规则请查看MSDN)来区别std ...

  10. js实现OSS上传图片,STS临时授权访问OSS

    1. 引入aliyun-oss-sdk.min.js <script type="text/javascript" src="/static/js/common/a ...