Skip to content

Basic

Flow

  • Load ansible.cfg.
  • Load inventory from ansible.cfg.
  • Exec biz yaml config file.
  • Load var file from biz config file.
  • Exec role main.yaml

Module

Debug

bash
- name: debug
  debug:
    msg: "命名空间:{{ monitor_namespace }},域名: {{ monitor_domain }}"

Ensure Directory

bash
- name: Ensure Directory
  file:
    dest: "{{ install_dir }}/monitor-platform/dashboard"
    state: directory

Command

bash
- name: "install yaml module"
  command:
    "yum -y install python3-pyyaml"
  ignore_errors: yes
  when:  ansible_os_family  == "Kylin Linux Advanced Server" and ansible_distribution_major_version == "V10" and ansible_architecture == "aarch64"

Copy Files

bash
- name: copy normal file
  copy:
    src: "{{ item }}"
    dest: "{{ install_dir }}/monitor-platform/{{ item }}"
  with_items:
  - datasource-secret.yaml

相对路径,会在 roles/monitor/files/ 查找文件。

Templates

bash
- name: Copy the Yaml file
  template:
    src: "{{ item }}.j2"
    dest: "{{ install_dir }}/monitor-platform/{{ item }}"
  with_items:
  - gateway.yaml
  - crd.yaml
  - grafana-virtual-service.yaml
  # vm 配置
  - vm-values.yaml
  - vm-agent-values.yaml
  - vm-operator-values.yaml
  - vm-cluster-values.yaml
  - grafana-values.yaml
  # grafana配置
  - grafana-ini-cm.yaml

.j2 模板文件放在 roles/monitor/templates 目录下,表示 Jinja2 模板。