wazuh-ansible-4.8.1/roles/elastic-stack/ansible-kibana/tasks/build_wazuh_plugin.yml
2019-11-21 13:29:03 +01:00

77 lines
2.3 KiB
YAML

---
- name: Ensure the Git package is present
package:
name: git
state: present
- name: Download script to install Nodejs repository
get_url:
url: "{{ node_js_repository_url }}"
dest: "/tmp/setup_nodejs_repo.sh"
mode: "0700"
- name: Execute downloaded script to install Nodejs repo
command: /tmp/setup_nodejs_repo.sh
register: node_repo_installation_result
changed_when: node_repo_installation_result.rc == 0
- name: Install Nodejs
package:
name: nodejs
state: present
- name: Run NPM under root account
command: npm config set user 0
register: allow_root_npm
changed_when: allow_root_npm.rc == 0
- name: Install yarn dependency to build the Wazuh Kibana Plugin
command: npm install -g yarn@1.10.1
register: install_yarn_result
changed_when: install_yarn_result == 0
- name: Remove old wazuh-kibana-app git directory
file:
path: /tmp/app
state: absent
- name: Clone wazuh-kibana-app repository # Using command as git module doesn't cover single-branch nor depth
command: git clone https://github.com/wazuh/wazuh-kibana-app -b {{ wazuh_plugin_branch }} --single-branch --depth=1 app # noqa 303
register: clone_app_repo_result
changed_when: clone_app_repo_result.rc == 0
args:
chdir: "/tmp"
- name: Executing yarn to build the package
command: "{{ item }}"
with_items:
- "yarn"
- "yarn build"
- "yarn build" # Executing multiple times to workaround errors returned by yarn build
register: yarn_execution_result
changed_when: yarn_execution_result == 0
args:
chdir: "/tmp/app/"
- name: Obtain name of generated package
shell: "find ./ -name 'wazuh-*.zip' -printf '%f\\n'"
register: wazuhapp_package_name
changed_when: false
args:
chdir: "/tmp/app/build"
- name: Install Wazuh Plugin (can take a while)
shell: "/usr/share/kibana/bin/kibana-plugin install file:///tmp/app/build/{{ wazuhapp_package_name.stdout }}"
environment:
NODE_OPTIONS: "--max-old-space-size=3072"
args:
executable: /bin/bash
creates: /usr/share/kibana/plugins/wazuh/package.json
become: yes
become_user: kibana
notify: restart kibana
tags:
- install
- skip_ansible_lint