saltstack 需要挂载点

saltstack require for mount point

所以我有一个基本的 saltstack 状态文件来安装和配置一个应用程序——在本例中是 influxdb。但是,我想要 salt 来管理块设备的安装,并在运行它之前由应用程序 required。

/opt/influxdb/shared/data/db:
  mount.mounted:
    - device: /dev/vdb1
    - fstype: ext4
    - mkmnt: True
    - opts:
      - defaults

influxdb:
  pkg.installed:
    - sources:
      - influxdb: salt://influxdb/influxdb-0.8.8-1.x86_64.rpm
  service.running:
    - require:
      - pkg: influxdb
    - watch:
      - file: /opt/influxdb/current/config.toml
  module.run:
    - name: influxdb.db_create
    - m_name: test_db

/opt/influxdb/current/config.toml:
  file.managed:
    - name: /opt/influxdb/current/config.toml
    - template: jinja
    - source:
      - salt://ptolemy/influxdb.toml

python-pip:
  pkg.installed

influxdb-python:
  pip.installed:
    - name: influxdb
    - require:
       - pkg: python-pip

我想我想要 influxdb 下的 service.running 下的东西。有人可以帮忙吗?

您需要在 require 下面添加一个新属性并列出其他要求。它应该是这样的:

influxdb:
  pkg.installed:
    - sources:
      - influxdb: salt://influxdb/influxdb-0.8.8-1.x86_64.rpm
  service.running:
    - require:
      - pkg: influxdb
      - mount: /opt/influxdb/shared/data/db
    - watch:
      - file: /opt/influxdb/current/config.toml

有关 require 的文档请参见此处:http://docs.saltstack.com/en/latest/ref/states/requisites.html