Saltstack
按鹽標記卷的問題,無論是狀態還是模組?
salt 如何標記 ec2 ebs 卷?我已經嘗試了所有我能想到的不同方法,但沒有一個有效:
首先,在配置文件中標記卷:
block_device_mappings: - DeviceName: /dev/sdb Ebs.VolumeSize: 10 Ebs.VolumeType: standard tags: { 'env': 'test' }
其次,標記鹽狀態的捲:
/dev/sdb: boto_ec2.volumes_tagged: - tag_maps: - filters: volume_ids: [ vol-0efe9141c40301871 ] #'attachment.device': /dev/xvdb - tags: env: test
執行狀態時出現錯誤:
Comment: An exception occurred in this state: Traceback (most recent call last): File "/var/tmp/.root_5c1176_salt/py2/salt/state.py", line 1745, in call **cdata['kwargs']) File "/var/tmp/.root_5c1176_salt/py2/salt/loader.py", line 1702, in wrapper return f(*args, **kwargs) File "/var/tmp/.root_5c1176_salt/py2/salt/states/boto_ec2.py", line 1209, in volumes_tagged r = __salt__['boto_ec2.set_volumes_tags'](**args) File "/var/tmp/.root_5c1176_salt/py2/salt/modules/boto_ec2.py", line 1647, in set_volumes_tags raise SaltInvocationError('Tag filters must be a dictionary: got {0}'.format(filters)) SaltInvocationError: Tag filters must be a dictionary: got None`
最後,查看了模組
boto_ec2.set_volumes_tags
,但我只是找不到語法以及如何放置過濾器和標籤。請任何人都可以告訴我如何用鹽標記卷。謝謝,羅傑
問題解決了。只需在此處發布解決方案,以防有人有類似問題:
它使用的
boto_ec2.volumes_tagged
狀態與我的原始狀態非常相似。但是,該格式比正常的鹽狀態有點不尋常:/dev/sdb: boto_ec2.volumes_tagged: # ec2_profile is defined in pillar - profile: ec2_profile - tag_maps: - filters: attachment.device: /dev/sdb tags: env: 'test'