nginx的role理解

1.整体文件框架

 2.调用主机和目标任务

[root@ks-allinone myansible_roles]# cat elasticsearch_service.yml 
---
- hosts: huidu
  roles:
  - role: elasticsearch

3.es配置

[root@ks-allinone elasticsearch]# cat files/elasticsearch.yml 
cluster.name: do1
node.name: node-1
path.data: /wxqyh/component/elasticsearch-6.2.2/data
path.logs: /wxqyh/component/elasticsearch-6.2.2/logs
network.host: 0.0.0.0
http.port: 9200

4.安装es步骤

[root@ks-allinone elasticsearch]# cat tasks/main.yml 
- include_tasks: install.yml
- include_tasks: config.yml
- include_tasks: start.yml
[root@ks-allinone elasticsearch]# cat tasks/install.yml 
- name: useradd esuser
  shell: useradd esuser

- name: unpackage software
  shell: tar -zxf /wxqyh/soft/elasticsearch-6.2.2.tar.gz -C /wxqyh/component/

- name: mkdir -p data
  shell: mkdir -p  /wxqyh/component/elasticsearch-6.2.2/data

- name: mkdir -p logs
  shell: mkdir -p /wxqyh/component/elasticsearch-6.2.2/logs

- name: change permission
  shell: chown -R esuser.esuser /wxqyh/component/elasticsearch-6.2.2/

- name: max map count
  shell: grep "vm.max_map_count" /etc/sysctl.conf || echo "vm.max_map_count = 655360" >> /etc/sysctl.conf

- name: soft nofile
  shell: grep 'esuser soft nofile 65535' /etc/security/limits.conf || sed -i '$i esuser soft nofile 65536' /etc/security/limits.conf

- name: hard nofile
  shell: grep 'esuser hard nofile 65535' /etc/security/limits.conf || sed -i '$i esuser hard nofile 65536' /etc/security/limits.conf

- name: sysctl -p
  shell: sysctl -p

- name: plugin install
  shell: /wxqyh/component/elasticsearch-6.2.2/bin/elasticsearch-plugin install file:////wxqyh/soft/elasticsearch-analysis-ik-6.2.2.zip
[root@ks-allinone elasticsearch]# cat tasks/start.yml 
- name: start es service
  shell: su esuser -c "/wxqyh/component/elasticsearch-6.2.2/bin/elasticsearch -d &"
[root@ks-allinone elasticsearch]# 

 参考: http://www.zhangblog.com/2020/01/09/ansible-12/

原文地址:https://www.cnblogs.com/hixiaowei/p/12964306.html