蔬菜小程序的开发全流程详解
822
2022-10-07
ansible-playbook安装nginx
1.创建一个ansible存放路径
[root@node02 scripts]# mkdir -p /home/monitor/ansible/nginx/{conf,bin}
2.编写nginx.yml文件
[root@node02:/home/monitor]$ cat /home/monitor/ansible/nginx/bin/nginx.yml - hosts: node01 remote_user: monitor become: yes become_method: sudo vars: hello: Ansible tasks: - name: Add repo yum_repository: name: nginx description: nginx repo baseurl: gpgcheck: no enabled: 1 - name: Install nginx yum: name: nginx state: latest - name: Copy nginx configuration file copy: src: /home/monitor/ansible/nginx/conf/site.conf dest: /etc/nginx/conf.d/site.conf - name: Start nginx service: name: nginx state: started - name: Create directory file: dest: /var/ state: directory - name: Create test page index.html shell: echo "hello {{hello}}" > /var/cat /home/monitor/ansible/nginx/conf/site.confserver { listen 80; server_name 192.168.56.101; location / { root /var/index index.html; }}
4.查看
[root@node02:/home/monitor]$ tree /home/monitor/ansible//home/monitor/ansible/└── nginx ├── bin │ └── nginx.yml └── conf └── site.conf3 directories, 2 files
5.check
[monitor@node02 bin]$ ansible-playbook -i /home/monitor/hosts /home/monitor/ansible/nginx/bin/nginx.yml --syntax-checkplaybook: /home/monitor/ansible/nginx/bin/nginx.yml
6.安装nginx
[monitor@node02 bin]$ ansible-playbook -i /home/monitor/hosts /home/monitor/ansible/nginx/bin/nginx.yml PLAY [node01] *************************************************************************************************************************************************************TASK [Gathering Facts] ****************************************************************************************************************************************************ok: [192.168.56.100]TASK [Add repo] ***********************************************************************************************************************************************************changed: [192.168.56.100]TASK [Install nginx] ******************************************************************************************************************************************************changed: [192.168.56.100]TASK [Copy nginx configuration file] **************************************************************************************************************************************changed: [192.168.56.100]TASK [Start nginx] ********************************************************************************************************************************************************changed: [192.168.56.100]TASK [Create directory] *******************************************************************************************************************************************ok: [192.168.56.100]TASK [Create test page index.html] ****************************************************************************************************************************************changed: [192.168.56.100]PLAY RECAP ****************************************************************************************************************************************************************192.168.56.100 : ok=7 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
7.检查nginx进程
[monitor@node02 bin]$ ansible -i /home/monitor/hosts node01 -m shell -a "ps -ef |grep nginx"192.168.56.100 | CHANGED | rc=0 >>root 14311 1 0 13:40 ? 00:00:00 nginx: master process /usr/sbin/nginxnginx 14312 14311 0 13:40 ? 00:00:00 nginx: worker processnginx 14313 14311 0 13:40 ? 00:00:00 nginx: worker processnginx 14314 14311 0 13:40 ? 00:00:00 nginx: worker processnginx 14315 14311 0 13:40 ? 00:00:00 nginx: worker processmonitor 16309 16304 0 13:58 pts/2 00:00:00 /bin/sh -c ps -ef |grep nginxmonitor 16311 16309 0 13:58 pts/2 00:00:00 grep nginx
ansible
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~