Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Role of ansible

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Note that all three need to be connected to the Internet.

Mine is 80.100, 80.101, 80.102

I operate on 80.100 as long as the other two are on. No need to operate.

Yum install-y epel-release / / install ansible source yum install ansible-yansible-- version / / View ansible version yum install tree-ycd / etc/ansiblevi hosts / / add [web] 192.168.80.10 [1:2] ansible all-- list-hosts shows all defined hosts ssh-keygen-t rsassh-copy-id root@192.168.80.101ssh-copy-id root@ on the last line of the configuration host list 192.168.80.102ansible all-a 'systemctl stop firewalld'ansible all-a' setenforce 0'mkdir-p / opt/roles/nginx/ {tasks Templates} cd / opt/roles/nginx/tasks/vi epel.yml- name: copy epel copy: src=/etc/yum.repos.d/ dest=/etc/yum.repos.d/vi user.yml- name: create user user: name=nginx group=nginx system=yes shell=/sbin/nologinvi group.yml- name: create group group: name=nginx system=yesvi yum.yml- name: install package yum: name=nginxvi start.yml- name: start service service: name=nginx state=restarted enabled=truevi restart.yml- name: restart service service: name=nginx state=restartedcd.. / templates/yum install-y Nginxcp / etc/nginx/nginx.conf nginx.conf.j2vi nginx.conf.j2worker_processes {{ansible_processor_vcpus}} Cd.. / tasks/vi temp.yml- name: copy conf file template: src=nginx.conf.j2 dest=/etc/nginx/nginx.confvi main.yml- include: epel.yml- include: group.yml- include: user.yml- include: yum.yml- include: temp.yml- include: start.ymlcd / etc/ansible/vi nginx_role.yml- hosts: web remote_user: root roles:-role: nginxtree roles/mkdir-p / etc/ansible/group_vars/touch / etc/ansible/group _ vars/allmkdir-p / etc/ansible/roles/commonmkdir-p / etc/ansible/roles/httpd/ {files Templates,tasks,handlers,vars,defaults,meta} mkdir-p / etc/ansible/roles/mysql/ {files,templates,tasks,handlers,vars,defaults,meta} mkdir-p / etc/ansible/roles/php/ {files,templates,tasks,handlers,vars,defaults,meta} touch / etc/ansible/roles/httpd/ {defaults,vars,tasks,meta,handlers} / main.ymltouch / etc/ansible/roles/mysql/ {defaults,vars,tasks,meta,handlers} / main.ymltouch / etc/ansible/roles/php/ {defaults,vars,tasks Meta,handlers} / main.ymlvi / etc/ansible/site.yml- hosts: web remote_user: root roles:-httpd-mysqlcd / opt/vi nginx.yml- hosts: web remote_user: root roles:-role: nginxansible web-a "rpm-Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm"ansible-playbook nginx.yml"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report