Ansible/elasticsearchの導入
をテンプレートにして作成
Search in
this wiki
and
or
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
*** pb_redmine_server-els_kibana.yml [#he718a56]
# install elasticsearch & kibana
# https://www.elastic.co/guide/en/elasticsearch/referenc...
# require httpd
- hosts: redmine_servers
become: true
become_method: su
environment: "{{ proxy_env }}"
tasks:
- name: facts check
fail:
msg: "Not compatible with [{{ ansible_os_family ...
when: ansible_os_family != 'RedHat' or ansible_dis...
- rpm_key:
key: https://artifacts.elastic.co/GPG-KEY-elasti...
state: present
- copy:
dest: /etc/yum.repos.d/elasticsearch.repo
force: no
content: |
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/...
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-el...
enabled=1
autorefresh=1
type=rpm-md
- name: install elasticsearch
yum:
name: elasticsearch
state: latest
- lineinfile:
dest: /etc/elasticsearch/elasticsearch.yml
line: "{{ item }}"
with_items:
- 'network.host: _local_,_site_'
- 'transport.host: _local_'
- name: start elasticsearch
systemd:
name: elasticsearch
state: started
daemon_reload: yes
enabled: yes
- firewalld:
port: 9200/tcp
state: enabled
permanent: true
immediate: yes
- copy:
dest: /etc/yum.repos.d/kibana.repo
force: no
content: |
[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/...
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-el...
enabled=1
autorefresh=1
type=rpm-md
- name: install kibana
yum:
name: kibana
state: latest
- lineinfile:
dest: /etc/kibana/kibana.yml
insertafter: '^#server.basePath: ""$'
line: 'server.basePath: "/kibana"'
- name: start kibana
systemd:
name: kibana
state: started
daemon_reload: yes
enabled: yes
- name: modify httpd.conf for kibana
copy:
dest: /etc/httpd/conf.d/proxy-kibana.conf
force: no
mode: 0644
content: |
<IfModule !proxy_module>
LoadModule proxy_module modules/mod_proxy.so
</IfModule>
<IfModule !proxy_http_module>
LoadModule proxy_http_module modules/mod_pro...
</IfModule>
ProxyPass /kibana http://localhost:5601...
ProxyPassReverse /kibana http://localhost:5601
notify:
- restart Apache
- name: httpd_can_network_connect
shell: /usr/sbin/getsebool httpd_can_network_connect
register: result01
- shell: /usr/sbin/setsebool -P httpd_can_network_co...
when: result01.stdout == 'httpd_can_network_connec...
notify:
- restart Apache
handlers:
- name: restart Apache
systemd:
name: httpd
state: restarted
daemon_reload: yes
ansible-playbook -i inventory.yml pb_redmine_server-els_...
*** pb_redmine_server-filebeat.yml [#z9752934]
# install filebeat
# https://www.elastic.co/guide/en/beats/filebeat/current...
- hosts: all
become: true
become_method: su
environment: "{{ proxy_env }}"
vars:
modules: system auditd apache elasticsearch kibana
els_host: its.jomura.net:9200
tasks:
- name: facts check
fail:
msg: "Not compatible with [{{ ansible_os_family ...
when: ansible_os_family != 'RedHat' or ansible_dis...
- rpm_key:
key: https://artifacts.elastic.co/GPG-KEY-elasti...
state: present
- copy:
dest: /etc/yum.repos.d/elasticsearch.repo
force: no
content: |
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/...
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-el...
enabled=1
autorefresh=1
type=rpm-md
- name: install filebeat
yum:
name: filebeat
state: latest
- lineinfile:
dest: /etc/filebeat/filebeat.yml
regexp: 'hosts: \["localhost:9200"\]'
line: " hosts: [\"{{ els_host }}\"]"
- shell: "
/usr/bin/filebeat modules enable {{ modules }}\n
/usr/bin/filebeat setup -e"
- name: start filebeat
systemd:
name: filebeat
state: started
daemon_reload: yes
enabled: yes
ansible-playbook -i srv1.jomura.net,srv2.jomura.net, pb_...
終了行:
*** pb_redmine_server-els_kibana.yml [#he718a56]
# install elasticsearch & kibana
# https://www.elastic.co/guide/en/elasticsearch/referenc...
# require httpd
- hosts: redmine_servers
become: true
become_method: su
environment: "{{ proxy_env }}"
tasks:
- name: facts check
fail:
msg: "Not compatible with [{{ ansible_os_family ...
when: ansible_os_family != 'RedHat' or ansible_dis...
- rpm_key:
key: https://artifacts.elastic.co/GPG-KEY-elasti...
state: present
- copy:
dest: /etc/yum.repos.d/elasticsearch.repo
force: no
content: |
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/...
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-el...
enabled=1
autorefresh=1
type=rpm-md
- name: install elasticsearch
yum:
name: elasticsearch
state: latest
- lineinfile:
dest: /etc/elasticsearch/elasticsearch.yml
line: "{{ item }}"
with_items:
- 'network.host: _local_,_site_'
- 'transport.host: _local_'
- name: start elasticsearch
systemd:
name: elasticsearch
state: started
daemon_reload: yes
enabled: yes
- firewalld:
port: 9200/tcp
state: enabled
permanent: true
immediate: yes
- copy:
dest: /etc/yum.repos.d/kibana.repo
force: no
content: |
[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/...
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-el...
enabled=1
autorefresh=1
type=rpm-md
- name: install kibana
yum:
name: kibana
state: latest
- lineinfile:
dest: /etc/kibana/kibana.yml
insertafter: '^#server.basePath: ""$'
line: 'server.basePath: "/kibana"'
- name: start kibana
systemd:
name: kibana
state: started
daemon_reload: yes
enabled: yes
- name: modify httpd.conf for kibana
copy:
dest: /etc/httpd/conf.d/proxy-kibana.conf
force: no
mode: 0644
content: |
<IfModule !proxy_module>
LoadModule proxy_module modules/mod_proxy.so
</IfModule>
<IfModule !proxy_http_module>
LoadModule proxy_http_module modules/mod_pro...
</IfModule>
ProxyPass /kibana http://localhost:5601...
ProxyPassReverse /kibana http://localhost:5601
notify:
- restart Apache
- name: httpd_can_network_connect
shell: /usr/sbin/getsebool httpd_can_network_connect
register: result01
- shell: /usr/sbin/setsebool -P httpd_can_network_co...
when: result01.stdout == 'httpd_can_network_connec...
notify:
- restart Apache
handlers:
- name: restart Apache
systemd:
name: httpd
state: restarted
daemon_reload: yes
ansible-playbook -i inventory.yml pb_redmine_server-els_...
*** pb_redmine_server-filebeat.yml [#z9752934]
# install filebeat
# https://www.elastic.co/guide/en/beats/filebeat/current...
- hosts: all
become: true
become_method: su
environment: "{{ proxy_env }}"
vars:
modules: system auditd apache elasticsearch kibana
els_host: its.jomura.net:9200
tasks:
- name: facts check
fail:
msg: "Not compatible with [{{ ansible_os_family ...
when: ansible_os_family != 'RedHat' or ansible_dis...
- rpm_key:
key: https://artifacts.elastic.co/GPG-KEY-elasti...
state: present
- copy:
dest: /etc/yum.repos.d/elasticsearch.repo
force: no
content: |
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/...
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-el...
enabled=1
autorefresh=1
type=rpm-md
- name: install filebeat
yum:
name: filebeat
state: latest
- lineinfile:
dest: /etc/filebeat/filebeat.yml
regexp: 'hosts: \["localhost:9200"\]'
line: " hosts: [\"{{ els_host }}\"]"
- shell: "
/usr/bin/filebeat modules enable {{ modules }}\n
/usr/bin/filebeat setup -e"
- name: start filebeat
systemd:
name: filebeat
state: started
daemon_reload: yes
enabled: yes
ansible-playbook -i srv1.jomura.net,srv2.jomura.net, pb_...
ページ名: