Showing
10 changed files
with
332 additions
and
0 deletions
roles/filebeat/README.md
0 → 100644
1 | +Openresty | ||
2 | +========= | ||
3 | + | ||
4 | +同步 `java nginx` 的配置文件,并且`reload nginx`. | ||
5 | + | ||
6 | +Requirements | ||
7 | +------------ | ||
8 | + | ||
9 | +依赖如下的hosts: | ||
10 | + - java-nginx | ||
11 | + - java-gateway | ||
12 | + - java-brower | ||
13 | + - java-wechat | ||
14 | + - java-activity | ||
15 | + - java-erpgateway | ||
16 | + - java-union | ||
17 | + | ||
18 | + | ||
19 | +Author Information | ||
20 | +------------------ | ||
21 | + | ||
22 | +chunhua.zhang@yoho.cn |
roles/filebeat/defaults/main.yml
0 → 100644
No preview for this file type
roles/filebeat/handlers/main.yml
0 → 100644
roles/filebeat/meta/main.yml
0 → 100644
1 | +galaxy_info: | ||
2 | + author: chunhua.zhang@yoho.cn | ||
3 | + description: update java openresty config | ||
4 | + company: yohobuy.com | ||
5 | + | ||
6 | + # If the issue tracker for your role is not on github, uncomment the | ||
7 | + # next line and provide a value | ||
8 | + # issue_tracker_url: http://example.com/issue/tracker | ||
9 | + | ||
10 | + # Some suggested licenses: | ||
11 | + # - BSD (default) | ||
12 | + # - MIT | ||
13 | + # - GPLv2 | ||
14 | + # - GPLv3 | ||
15 | + # - Apache | ||
16 | + # - CC-BY | ||
17 | + license: license (GPLv2, CC-BY, etc) | ||
18 | + | ||
19 | + min_ansible_version: 1.2 | ||
20 | + | ||
21 | + # If this a Container Enabled role, provide the minimum Ansible Container version. | ||
22 | + # min_ansible_container_version: | ||
23 | + | ||
24 | + # Optionally specify the branch Galaxy will use when accessing the GitHub | ||
25 | + # repo for this role. During role install, if no tags are available, | ||
26 | + # Galaxy will use this branch. During import Galaxy will access files on | ||
27 | + # this branch. If Travis integration is configured, only notifications for this | ||
28 | + # branch will be accepted. Otherwise, in all cases, the repo's default branch | ||
29 | + # (usually master) will be used. | ||
30 | + #github_branch: | ||
31 | + | ||
32 | + # | ||
33 | + # platforms is a list of platforms, and each platform has a name and a list of versions. | ||
34 | + # | ||
35 | + # platforms: | ||
36 | + # - name: Fedora | ||
37 | + # versions: | ||
38 | + # - all | ||
39 | + # - 25 | ||
40 | + # - name: SomePlatform | ||
41 | + # versions: | ||
42 | + # - all | ||
43 | + # - 1.0 | ||
44 | + # - 7 | ||
45 | + # - 99.99 | ||
46 | + | ||
47 | + galaxy_tags: [] | ||
48 | + # List tags for your role here, one per line. A tag is a keyword that describes | ||
49 | + # and categorizes the role. Users find roles by searching for tags. Be sure to | ||
50 | + # remove the '[]' above, if you add tags to this list. | ||
51 | + # | ||
52 | + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. | ||
53 | + # Maximum 20 tags per role. | ||
54 | + | ||
55 | +dependencies: [] | ||
56 | + # List your role dependencies here, one per line. Be sure to remove the '[]' above, | ||
57 | + # if you add dependencies to this list. |
roles/filebeat/tasks/main.yml
0 → 100644
1 | +--- | ||
2 | +# tasks file for filebeat | ||
3 | + | ||
4 | + | ||
5 | +# make sure user type YES | ||
6 | +- name: "make sure user type YES to confirm" | ||
7 | + fail: | ||
8 | + msg: "user do not type YES" | ||
9 | + when: confirmation != 'YES' | ||
10 | + | ||
11 | +# make sure path exist | ||
12 | +- stat: | ||
13 | + path: "{{ path }}" | ||
14 | + register: stat_result | ||
15 | + | ||
16 | +- name: "Init the filebeat if filebeat not exist" | ||
17 | + copy: | ||
18 | + src: filebeat-5.6.4-linux-x86_64.tar.gz | ||
19 | + dest: "{{ package }}" | ||
20 | + command: "tar -zxvf {{ package }} -C {{ home }}" | ||
21 | + when: stat_result.stat.exists == False | ||
22 | + | ||
23 | + | ||
24 | +# make sure group exists | ||
25 | +- name: make sure groups exist in inventory file | ||
26 | + fail: | ||
27 | + msg: "group {{ item }} not exist!" | ||
28 | + when: item not in groups | ||
29 | + with_items: | ||
30 | + - nameservers | ||
31 | + - java-nginx | ||
32 | + - java-gateway | ||
33 | + - java-brower | ||
34 | + - java-wechat | ||
35 | + - java-activity | ||
36 | + - java-erpgateway | ||
37 | + - java-union | ||
38 | + | ||
39 | + | ||
40 | +- name: update nginx upstream for file -nginx.conf | ||
41 | + template: | ||
42 | + src: nginx.conf.j2 | ||
43 | + dest: "{{ path }}/nginx/conf/nginx.conf" | ||
44 | + notify: | ||
45 | + - reload nginx |
roles/filebeat/templates/nginx.conf.j2
0 → 100644
1 | +user www www; | ||
2 | + | ||
3 | +worker_processes 8; | ||
4 | +worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; | ||
5 | + | ||
6 | +pid logs/nginx.pid; | ||
7 | +# [ debug | info | notice | warn | error | crit ] | ||
8 | +#error_log /Data/logs/nginx/nginx_error.log info; | ||
9 | +error_log /Data/logs/nginx/nginx_error.log info; | ||
10 | +#Specifies the value for maximum file descriptors that can be opened by this process. | ||
11 | +worker_rlimit_nofile 51200; | ||
12 | + | ||
13 | +events | ||
14 | +{ | ||
15 | + use epoll; | ||
16 | + | ||
17 | + #maxclient = worker_processes * worker_connections / cpu_number | ||
18 | + worker_connections 51200; | ||
19 | +} | ||
20 | + | ||
21 | +http | ||
22 | +{ | ||
23 | + include mime.types; | ||
24 | + default_type application/octet-stream; | ||
25 | + #charset gb2312,utf-8; | ||
26 | + charset utf-8; | ||
27 | + | ||
28 | + log_format fenxi '$remote_addr|$http_x_forwarded_for|[$time_local]|$http_host|$request|' | ||
29 | + '$status|$body_bytes_sent|$request_time|$upstream_response_time|$upstream_cache_status|$http_referer|' | ||
30 | + '$http_user_agent|$upstream_addr'; | ||
31 | + | ||
32 | + # resolver: local dns servers | ||
33 | + resolver {% for i in groups['nameservers'] %} {{ i }} {% endfor %}; | ||
34 | + | ||
35 | + | ||
36 | + #General Options | ||
37 | + server_names_hash_bucket_size 128; | ||
38 | + client_header_buffer_size 32k; | ||
39 | + large_client_header_buffers 4 32k; | ||
40 | + client_body_buffer_size 8m; #256k | ||
41 | + # | ||
42 | + #server_tokens off; | ||
43 | + ignore_invalid_headers on; | ||
44 | + recursive_error_pages on; | ||
45 | + server_name_in_redirect off; | ||
46 | + | ||
47 | + sendfile on; | ||
48 | + | ||
49 | + #timeouts | ||
50 | + keepalive_timeout 75s; | ||
51 | + keepalive_requests 10000; | ||
52 | + #test | ||
53 | + #client_body_timeout 3m; | ||
54 | + #client_header_timeout 3m; | ||
55 | + #send_timeout 3m; | ||
56 | + | ||
57 | + | ||
58 | + #TCP Options | ||
59 | + tcp_nopush on; | ||
60 | + tcp_nodelay on; | ||
61 | + | ||
62 | + #fastcgi options | ||
63 | + fastcgi_connect_timeout 300; | ||
64 | + fastcgi_send_timeout 300; | ||
65 | + fastcgi_read_timeout 300; | ||
66 | + fastcgi_buffer_size 64k; | ||
67 | + fastcgi_buffers 4 64k; | ||
68 | + fastcgi_busy_buffers_size 128k; | ||
69 | + fastcgi_temp_file_write_size 128k; | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + #hiden php version | ||
74 | + fastcgi_hide_header X-Powered-By; | ||
75 | + | ||
76 | + #size limits | ||
77 | + client_max_body_size 50m; | ||
78 | + | ||
79 | + gzip on; | ||
80 | + gzip_min_length 1k; | ||
81 | + gzip_buffers 4 16k; | ||
82 | + #gzip_http_version 1.0; | ||
83 | + gzip_comp_level 2; | ||
84 | + gzip_types text/plain application/x-javascript text/css application/xml application/json; | ||
85 | + gzip_vary on; | ||
86 | + | ||
87 | + add_header x-yh-nginx-dc {{ dc }}; | ||
88 | + | ||
89 | + | ||
90 | + | ||
91 | + fastcgi_temp_path /dev/shm/fastcgi_temp; | ||
92 | + client_body_temp_path /dev/shm/client_body_temp; | ||
93 | + | ||
94 | + # where the lua package exists | ||
95 | + lua_package_path "/Data/local/openresty-1.9.15.1/nginx/conf/lua/?.lua;;"; | ||
96 | + init_by_lua_file "conf/lua/init_lua.lua"; | ||
97 | + lua_shared_dict luacachedb 500m; | ||
98 | + lua_shared_dict malips 10m; | ||
99 | + lua_shared_dict ngxconf 20m; | ||
100 | + init_worker_by_lua_file "conf/lua/init_config_worker.lua"; | ||
101 | + | ||
102 | + #brower service | ||
103 | + upstream brower { | ||
104 | + {% for i in groups['java-brower'] %} | ||
105 | + server {{ i }}:8092; | ||
106 | + {% endfor %} | ||
107 | + | ||
108 | + keepalive 100; | ||
109 | + } | ||
110 | + | ||
111 | + | ||
112 | + | ||
113 | + #apigatewaystart | ||
114 | + upstream apigateway { | ||
115 | + | ||
116 | + {% for i in groups['java-gateway'] %} | ||
117 | + server {{ i }}:8080 max_fails=5 fail_timeout=3s; | ||
118 | + {% endfor %} | ||
119 | + | ||
120 | + keepalive 32; | ||
121 | + } | ||
122 | + #apigatewayend | ||
123 | + | ||
124 | + | ||
125 | + | ||
126 | + | ||
127 | + # activity | ||
128 | + upstream activityApi{ | ||
129 | + | ||
130 | + {% for i in groups['java-activity'] %} | ||
131 | + server {{ i }}:8090; | ||
132 | + {% endfor %} | ||
133 | + | ||
134 | + keepalive 100; | ||
135 | + } | ||
136 | + | ||
137 | + | ||
138 | |||
139 | + upstream apiWechat { | ||
140 | + | ||
141 | + {% for i in groups['java-wechat'] %} | ||
142 | + server {{ i }}:8094; | ||
143 | + {% endfor %} | ||
144 | + | ||
145 | + keepalive 100; | ||
146 | + } | ||
147 | + | ||
148 | + # erp gateway | ||
149 | + upstream erpgateway { | ||
150 | + | ||
151 | + {% for i in groups['java-erpgateway'] %} | ||
152 | + server {{ i }}:8089; | ||
153 | + {% endfor %} | ||
154 | + | ||
155 | + keepalive 100; | ||
156 | + } | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + # union servers | ||
161 | + upstream union_pools { | ||
162 | + server 10.66.70.21:8088; | ||
163 | + server 10.66.70.49:8088; | ||
164 | + server 10.66.202.49:8088; | ||
165 | + | ||
166 | + } | ||
167 | + | ||
168 | + | ||
169 | + | ||
170 | + #upstream | ||
171 | + fastcgi_next_upstream error timeout invalid_header http_500; | ||
172 | + | ||
173 | + #limit_zone limit $binary_remote_addr 1m; | ||
174 | + | ||
175 | + #fastcgi cache | ||
176 | + #fastcgi_cache_path /nginxcache levels=1:2 keys_zone=two:10m inactive=1d max_size=3000m; | ||
177 | + #for example just for study! have fun! | ||
178 | + | ||
179 | + | ||
180 | + include vhosts/api.yoho.cn.conf; | ||
181 | + include vhosts/api_single.yoho.cn.conf; | ||
182 | + include vhosts/erp.yoho.yohoops.org.conf; | ||
183 | + include vhosts/single.conf; | ||
184 | + include vhosts/union.yoho.cn.conf; | ||
185 | + | ||
186 | + } |
roles/filebeat/tests/inventory
0 → 100644
roles/filebeat/tests/test.yml
0 → 100644
roles/filebeat/vars/main.yml
0 → 100644
-
Please register or login to post a comment