- name: add group nginx user: name=nginx state=present - name: add user nginx user: name=nginx state=present group=nginx - name: Install Nginx yum: name=nginx state=present - name: web page copy: src=files/index.html dest=/usr/share/nginx/html/index.html - name: Start Nginx service...
shell: chdir=/usr/local/src tar -zxf nginx-1.12.2.tar.gz - name: install nginx shell: chdir=/usr/local/src/nginx-1.12.2 ./configure && make && make install - name: copy nginx.conf template: src=nginx.conf.j2 dest=/usr/local/nginx/conf/nginx.conf - name: copy index.html template...
2. 编写playbook的nginx安装yaml文件 1) 编写nginx.yaml配置文件 1[root@test-1 bin]#vim /ansible/nginx/bin/nginx.yaml2[root@test-1 bin]#cat /ansible/nginx/bin/nginx.yaml3-hosts: web14remote_user: root5vars:6hello: Ansible78tasks:9-name: Add repo10yum_repository:11name: nginx12description...
[monitor@node02 bin]$ ansible-playbook -i /home/monitor/hosts /home/monitor/ansible/nginx/bin/nginx.yml --syntax-check playbook: /home/monitor/ansible/nginx/bin/nginx.yml 1. 2. 3. 6.安装nginx [monitor@node02 bin]$ ansible-playbook -i /home/monitor/hosts /home/monitor/ansible/nginx/bin...
PlayBooks //剧本,定义没个主机扮演的角色 Hosts. //主机 roles. //角色 Connection Plugins. //连接插件,连接至被管控主机,完成并发连接,默认一次管理5台,但是可以修改。 三、安装配置 ★安装: # yum install ansible -y(epel仓库中) ★程序: ansible ...
家里的服务器新开了两台虚拟机,想做nginx负载均衡的实验,但是要重新安装各种服务,就很麻烦,正好最近学了ansible-playbook,就想试着写一下一键部署脚本 代码 具体的安装方式我前几篇博客已经说了 话不都说,上代码 vi installnginx.yml - hosts: test2
例如,下面是一个playbook示例,文件名为first.yml,内容如下: --- -name:play1 hosts:nginx gather_facts:false tasks: -name:task1inplay1 debug: msg:"output task1 in play1" -name:task2inplay1 debug: msg:"output task2 in play1" -name:play2 ...
8、nginx_install文件夹下的files存放nginx-1.4.3的压缩包 9、相关的参数存放在vars的mail.yml中,可根据需要自己更改: 10、具体的安装步骤如下: 下载nginx_install.rar文件。https://pan.baidu.com/s/11jR-2W7XO6fk632tfdYrAw 解压后:ansible-playbook /你的路径/nginx_install.yml --extra-vars "host=你...
Above output confirms, ping connectivity is fine between control and managed node. Let’s create a demo ansible playbook to install nginx on managed node. 上面的输出表明,控制节点和托管节点之间的 PING 连接良好。让我们创建一个 ansible playbook 演示 ,用以在托管节点上安装 NGINX。
[root@k8s3~]$ cat/etc/ansible/nginx_install/install.yml---hosts:192.168.3.42remote_user:root gather_facts:Trueroles:-common-install 执行ansible playbook安装nginx [root@k8s3~]$ ansible-playbook/etc/ansible/nginx_install/install.yml 执行结果 验证...