未解決
Moderator
•
6.5K メッセージ
0
341
【七転び八起き】PowerStore3.0でAnsibleを使うときの注意
PowerStore3.0でAnsibleを使おうとしてはまった話です。
七転び八起きなので結構余計なつまづきがありますが備忘録もかねてそのまま書きます。
問題:今まで使えていたYmlファイルがエラーで使えない・・・
TASK [Create multiple volumes] *************************************************
failed: [localhost] (item=1) => {"ansible_loop_var": "item", "changed": false, "error_code": 1, "item": 1, "msg": "Got error HTTP code: 400, Bad Request [{'messages': [{'code': '0xE04040020008', 'severity': 'Error', 'message_l10n': 'Unable to parse passed url.'}]}] while getting details of volume", "status_code": "400"}
原因:インストールしていたAnsible Collectionが古かった! (最新版は1.6)
参考サイト:https://github.com/dell/ansible-powerstore
/ansible_collections/dellemc/powerstore/MANIFEST.jsonにて確認すると以下で1.4でした。
MANIFEST.jsonからの抜粋>
"collection_info": {
"namespace": "dellemc",
"name": "powerstore",
"version": "1.4.0",
対応策:最新版のAnsible Collectionを入れる!
参考サイト:https://github.com/dell/ansible-powersto
①ansible_collectionsのあるDirectory にて以下実行
# pip install PyPowerStore
# ansible-galaxy collection install dellemc.powerstore -p <インストール場所>
中略>
All requested collections are already installed. If you want to reinstall them, consider using `--force`.
⇒エラーが出た!
なので言う通りに--forceつけて再度実行
# ansible-galaxy collection install dellemc.powerstore -p /home/ayasaito --force
中略>
Installing 'dellemc.powerstore:1.6.0' to '/home/ayasaito/ansible_collections/dellemc/powerstore'
dellemc.powerstore:1.6.0 was installed successfully
⇒成功!
②テストYmlを実行したらまたエラー!PyPowerStore 1.5.0.0ではだめらしい・・・
TASK [Create multiple volumes] *************************************************
failed: [localhost] (item=1) => {"ansible_loop_var": "item", "changed": false, "item": 1, "msg": "PyPowerStore 1.5.0.0 is not supported by this module. Minimum supported version is : 1.7.0 "}
③PyPowerStore1.7を入れる。 (参考:https://github.com/dell/python-powerstore )
# pip install PyPowerStore==1.7.0.0
Collecting PyPowerStore==1.7.0.0
③再びテストYmlを実行
# ansible-playbook test.yml
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
controller starting with Ansible 2.12. Current version: 3.6.8 (default, Nov 9
2021, 16:02:49) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]. This feature will be
removed from ansible-core in version 2.12. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
[WARNING]: running playbook inside collection dellemc.powerstore
PLAY [Creation of Multiple Volume] *********************************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [Create multiple volumes] *************************************************
changed: [localhost] => (item=1)
changed: [localhost] => (item=2)
changed: [localhost] => (item=3)
PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
⇒成功!
ちなみに使用したYmlファイル構文はこちら=====
「Volume_Moduleという3Gのボリュームを3つある状態にする」
# This playbook illustrates the creation of multiple volumes sequentially
---
- name: Creation of Multiple Volume
hosts: localhost
connection: local
vars:
array_ip: 'PowerStoreのIP'
user: 'ユーザー'
password: 'パスワード'
verifycert: False
vol_name: 'Volume_Module'
cap_unit: 'GB'
collections:
- dellemc.powerstore
tasks:
- name: Create multiple volumes
register: result_vol
volume:
array_ip: "{ {array_ip}}"
user: "{ {user}}"
password: "{ {password}}"
verifycert: "{ {verifycert}}"
vol_name: "{ {vol_name +'_' }}{ {item}}"
size: 3
cap_unit: "{ {cap_unit}}"
state: 'present'
# The loop will be executed for the number of elements in the list(created by the range).
loop: "{ { range(1,3+ 1,1) | list }}"