😵
Azure Cloud Shell 環境からの Ansible の使用ができなくなった話
はじめに
Azure Cloud Shell 環境からの Ansible の使用 便利ですよね。
今回は、
・2021/11 に作成したAzure NSGの設定変更する ansible playbook を実行できていた。
・2022/01/26 現在、Azure Cloud Shell上で同じansible playbookを実行するとエラーになって実行できなくなった!?
という事象があったので、とりあえず実行できる環境に設定変更する方法を記載します。
環境
- Azure Cloud Shell
- ansible 2.10.2 -> core 2.11.7
- azure.azcollection
- Python 3.7.3
忙しい人用
下記実行すればとりあえず動くようになります。
$ pip install --upgrade pip
$ pip install --upgrade ansible
$ wget -nv -q https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt
$ pip install -r requirements-azure.txt
$ ansible-galaxy collection install azure.azcollection
<Cloud Shell 再起動>
$ ansible --version
詳細
事前確認
$ ansible --version
$ python -V
結果
r_ota@Azure:~$ ansible --version
ansible 2.10.2
config file = None
configured module search path = ['/home/r_ota/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/ansible/lib/python3.7/site-packages/ansible
executable location = /opt/ansible/bin/ansible
python version = 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
r_ota@Azure:~$ python -V
Python 3.7.3
r_ota@Azure:~$
エラーデモ
$ ansible-playbook run.yml --extra-vars "importjson=./import.json" --check
結果
r_ota@Azure:~$ ansible-playbook run.yml --extra-vars "importjson=./import.json" --check
[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'
PLAY [localhost] ****************************************************************************************************************************************************************************************************************************
TASK [Azure Security Group] *****************************************************************************************************************************************************************************************************************
TASK [az_securitygroup : Network Security group "r_ota-nsg_test1" Rule "AllowAzureStorageInbound" modify] ***********************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'azure.mgmt.monitor.version'
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on cc-8fbfa57e-6b577f4858-6hrc4's Python /opt/ansible/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
r_ota@Azure:~$
設定変更1(upgrade pip/ansible)
実行
$ pip install --upgrade pip
$ pip install --upgrade ansible
結果
r_ota@Azure:~$ pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
|████████████████████████████████| 1.7 MB 23.0 MB/s
Installing collected packages: pip
WARNING: The scripts pip, pip3 and pip3.7 are installed in '/home/r_ota/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
Successfully installed pip-21.3.1
WARNING: You are using pip version 20.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
r_ota@Azure:~$ pip install --upgrade ansible
Defaulting to user installation because normal site-packages is not writeable
Collecting ansible
Downloading ansible-4.10.0.tar.gz (36.8 MB)
|████████████████████████████████| 36.8 MB 206 kB/s
Preparing metadata (setup.py) ... done
Collecting ansible-core~=2.11.7
Downloading ansible-core-2.11.7.tar.gz (7.1 MB)
|████████████████████████████████| 7.1 MB 57.2 MB/s
Preparing metadata (setup.py) ... done
Requirement already satisfied: PyYAML in /usr/local/lib/python3.7/dist-packages (from ansible-core~=2.11.7->ansible) (5.3.1)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-core~=2.11.7->ansible) (2.6.1)
Collecting jinja2
Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
|████████████████████████████████| 133 kB 56.8 MB/s
Collecting packaging
Downloading packaging-21.3-py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB 1.6 MB/s
Collecting resolvelib<0.6.0,>=0.5.3
Downloading resolvelib-0.5.4-py2.py3-none-any.whl (12 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (31 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
Downloading pyparsing-3.0.7-py3-none-any.whl (98 kB)
|████████████████████████████████| 98 kB 958 kB/s
Building wheels for collected packages: ansible, ansible-core
Building wheel for ansible (setup.py) ... done
Created wheel for ansible: filename=ansible-4.10.0-py3-none-any.whl size=60568513 sha256=3663b68c74a062b625a8de80b3b94e47e1f98b0e2fc999bb82a45bea79e03dc8
Stored in directory: /home/r_ota/.cache/pip/wheels/63/73/49/abc8cc94c80bbc9ffa3d4dad9e860562e7d2929312a7977463
Building wheel for ansible-core (setup.py) ... done
Created wheel for ansible-core: filename=ansible_core-2.11.7-py3-none-any.whl size=1959477 sha256=bc9ce7aa9d0bd34060ac0b2b2e5ab19c2ab35be1ad5c262aa8dfa97d5e93ee50
Stored in directory: /home/r_ota/.cache/pip/wheels/08/e1/3c/25f801195e694b2c03e387f618a1003c83a23b4e92f684536a
Successfully built ansible ansible-core
Installing collected packages: pyparsing, MarkupSafe, resolvelib, packaging, jinja2, ansible-core, ansible
Successfully installed MarkupSafe-2.0.1 ansible-4.10.0 ansible-core-2.11.7 jinja2-3.0.3 packaging-21.3 pyparsing-3.0.7 resolvelib-0.5.4
r_ota@Azure:~$
設定変更2
実行
$ wget -nv -q https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt
$ pip install -r requirements-azure.txt
結果
r_ota@Azure:~$ wget -nv -q https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt
r_ota@Azure:~$ pip install -r requirements-azure.txt
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: packaging in ./.local/lib/python3.7/site-packages (from -r requirements-azure.txt (line 1)) (21.3)
Requirement already satisfied: requests[security] in /usr/local/lib/python3.7/dist-packages (from -r requirements-azure.txt (line 2)) (2.24.0)
Collecting xmltodict
Downloading xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)
Collecting azure-cli-core==2.26.1
Downloading azure_cli_core-2.26.1-py3-none-any.whl (178 kB)
|████████████████████████████████| 178 kB 32.5 MB/s
Collecting azure-common==1.1.11
Downloading azure_common-1.1.11-py2.py3-none-any.whl (9.7 kB)
Collecting azure-identity==1.7.0
Downloading azure_identity-1.7.0-py2.py3-none-any.whl (129 kB)
|████████████████████████████████| 129 kB 58.0 MB/s
Collecting azure-mgmt-apimanagement==0.2.0
Downloading azure_mgmt_apimanagement-0.2.0-py2.py3-none-any.whl (275 kB)
|████████████████████████████████| 275 kB 46.5 MB/s
Collecting azure-mgmt-authorization==0.51.1
Downloading azure_mgmt_authorization-0.51.1-py2.py3-none-any.whl (111 kB)
|████████████████████████████████| 111 kB 61.3 MB/s
Collecting azure-mgmt-batch==5.0.1
Downloading azure_mgmt_batch-5.0.1-py2.py3-none-any.whl (87 kB)
|████████████████████████████████| 87 kB 1.5 MB/s
Collecting azure-mgmt-cdn==3.0.0
Downloading azure_mgmt_cdn-3.0.0-py2.py3-none-any.whl (108 kB)
|████████████████████████████████| 108 kB 57.5 MB/s
Collecting azure-mgmt-compute==10.0.0
Downloading azure_mgmt_compute-10.0.0-py2.py3-none-any.whl (1.4 MB)
|████████████████████████████████| 1.4 MB 30.1 MB/s
Collecting azure-mgmt-containerinstance==1.4.0
Downloading azure_mgmt_containerinstance-1.4.0-py2.py3-none-any.whl (87 kB)
|████████████████████████████████| 87 kB 1.2 MB/s
Collecting azure-mgmt-containerregistry==2.0.0
Downloading azure_mgmt_containerregistry-2.0.0-py2.py3-none-any.whl (274 kB)
|████████████████████████████████| 274 kB 46.0 MB/s
Collecting azure-mgmt-containerservice==9.1.0
Downloading azure_mgmt_containerservice-9.1.0-py2.py3-none-any.whl (545 kB)
|████████████████████████████████| 545 kB 37.5 MB/s
Collecting azure-mgmt-datalake-store==0.5.0
Downloading azure_mgmt_datalake_store-0.5.0-py2.py3-none-any.whl (88 kB)
|████████████████████████████████| 88 kB 2.1 MB/s
Collecting azure-mgmt-dns==2.1.0
Downloading azure_mgmt_dns-2.1.0-py2.py3-none-any.whl (134 kB)
|████████████████████████████████| 134 kB 57.0 MB/s
Collecting azure-mgmt-keyvault==1.1.0
Downloading azure_mgmt_keyvault-1.1.0-py2.py3-none-any.whl (111 kB)
|████████████████████████████████| 111 kB 50.5 MB/s
Collecting azure-mgmt-marketplaceordering==0.1.0
Downloading azure_mgmt_marketplaceordering-0.1.0-py2.py3-none-any.whl (16 kB)
Collecting azure-mgmt-monitor==3.0.0
Downloading azure_mgmt_monitor-3.0.0-py2.py3-none-any.whl (839 kB)
|████████████████████████████████| 839 kB 65.5 MB/s
Collecting azure-mgmt-managedservices==1.0.0
Downloading azure_mgmt_managedservices-1.0.0-py2.py3-none-any.whl (38 kB)
Collecting azure-mgmt-managementgroups==0.2.0
Downloading azure_mgmt_managementgroups-0.2.0-py2.py3-none-any.whl (59 kB)
|████████████████████████████████| 59 kB 1.1 MB/s
Collecting azure-mgmt-network==12.0.0
Downloading azure_mgmt_network-12.0.0-py2.py3-none-any.whl (9.6 MB)
|████████████████████████████████| 9.6 MB 25.0 MB/s
Collecting azure-mgmt-nspkg==2.0.0
Downloading azure_mgmt_nspkg-2.0.0-py2.py3-none-any.whl (2.8 kB)
Collecting azure-mgmt-privatedns==0.1.0
Downloading azure_mgmt_privatedns-0.1.0-py2.py3-none-any.whl (44 kB)
|████████████████████████████████| 44 kB 687 kB/s
Collecting azure-mgmt-redis==5.0.0
Downloading azure_mgmt_redis-5.0.0-py2.py3-none-any.whl (43 kB)
|████████████████████████████████| 43 kB 512 kB/s
Collecting azure-mgmt-resource==10.2.0
Downloading azure_mgmt_resource-10.2.0-py2.py3-none-any.whl (968 kB)
|████████████████████████████████| 968 kB 38.8 MB/s
Collecting azure-mgmt-rdbms==1.9.0
Downloading azure_mgmt_rdbms-1.9.0-py2.py3-none-any.whl (259 kB)
|████████████████████████████████| 259 kB 58.3 MB/s
Collecting azure-mgmt-search==3.0.0
Downloading azure_mgmt_search-3.0.0-py2.py3-none-any.whl (43 kB)
|████████████████████████████████| 43 kB 418 kB/s
Collecting azure-mgmt-servicebus==0.5.3
Downloading azure_mgmt_servicebus-0.5.3-py2.py3-none-any.whl (112 kB)
|████████████████████████████████| 112 kB 53.1 MB/s
Collecting azure-mgmt-sql==0.10.0
Downloading azure_mgmt_sql-0.10.0-py2.py3-none-any.whl (541 kB)
|████████████████████████████████| 541 kB 52.2 MB/s
Collecting azure-mgmt-storage==11.1.0
Downloading azure_mgmt_storage-11.1.0-py2.py3-none-any.whl (547 kB)
|████████████████████████████████| 547 kB 57.9 MB/s
Collecting azure-mgmt-trafficmanager==0.50.0
Downloading azure_mgmt_trafficmanager-0.50.0-py2.py3-none-any.whl (52 kB)
|████████████████████████████████| 52 kB 414 kB/s
Collecting azure-mgmt-web==0.41.0
Downloading azure_mgmt_web-0.41.0-py2.py3-none-any.whl (645 kB)
|████████████████████████████████| 645 kB 57.3 MB/s
Collecting azure-nspkg==2.0.0
Downloading azure_nspkg-2.0.0-py2.py3-none-any.whl (2.6 kB)
Collecting azure-storage==0.35.1
Downloading azure_storage-0.35.1-py2.py3-none-any.whl (190 kB)
|████████████████████████████████| 190 kB 56.9 MB/s
Collecting msrest==0.6.21
Downloading msrest-0.6.21-py2.py3-none-any.whl (85 kB)
|████████████████████████████████| 85 kB 963 kB/s
Requirement already satisfied: msrestazure==0.6.4 in /usr/local/lib/python3.7/dist-packages (from -r requirements-azure.txt (line 37)) (0.6.4)
Collecting azure-keyvault==1.0.0a1
Downloading azure_keyvault-1.0.0a1-py2.py3-none-any.whl (109 kB)
|████████████████████████████████| 109 kB 54.6 MB/s
Collecting azure-graphrbac==0.61.1
Downloading azure_graphrbac-0.61.1-py2.py3-none-any.whl (141 kB)
|████████████████████████████████| 141 kB 54.7 MB/s
Collecting azure-mgmt-cosmosdb==0.5.2
Downloading azure_mgmt_cosmosdb-0.5.2-py2.py3-none-any.whl (101 kB)
|████████████████████████████████| 101 kB 1.6 MB/s
Collecting azure-mgmt-hdinsight==0.1.0
Downloading azure_mgmt_hdinsight-0.1.0-py2.py3-none-any.whl (117 kB)
|████████████████████████████████| 117 kB 54.5 MB/s
Collecting azure-mgmt-devtestlabs==3.0.0
Downloading azure_mgmt_devtestlabs-3.0.0-py2.py3-none-any.whl (381 kB)
|████████████████████████████████| 381 kB 47.2 MB/s
Collecting azure-mgmt-loganalytics==1.0.0
Downloading azure_mgmt_loganalytics-1.0.0-py2.py3-none-any.whl (79 kB)
|████████████████████████████████| 79 kB 1.1 MB/s
Collecting azure-mgmt-automation==0.1.1
Downloading azure_mgmt_automation-0.1.1-py2.py3-none-any.whl (380 kB)
|████████████████████████████████| 380 kB 27.3 MB/s
Collecting azure-mgmt-iothub==0.7.0
Downloading azure_mgmt_iothub-0.7.0-py2.py3-none-any.whl (131 kB)
|████████████████████████████████| 131 kB 57.7 MB/s
Collecting azure-mgmt-recoveryservices==0.4.0
Downloading azure_mgmt_recoveryservices-0.4.0-py2.py3-none-any.whl (77 kB)
|████████████████████████████████| 77 kB 1.8 MB/s
Collecting azure-mgmt-recoveryservicesbackup==0.6.0
Downloading azure_mgmt_recoveryservicesbackup-0.6.0-py2.py3-none-any.whl (194 kB)
|████████████████████████████████| 194 kB 54.0 MB/s
Collecting azure-mgmt-notificationhubs==2.0.0
Downloading azure_mgmt_notificationhubs-2.0.0-py2.py3-none-any.whl (71 kB)
|████████████████████████████████| 71 kB 15 kB/s
Collecting azure-mgmt-eventhub==2.0.0
Downloading azure_mgmt_eventhub-2.0.0-py2.py3-none-any.whl (67 kB)
|████████████████████████████████| 67 kB 1.2 MB/s
Collecting humanfriendly<10.0,>=4.7
Downloading humanfriendly-9.2-py2.py3-none-any.whl (86 kB)
|████████████████████████████████| 86 kB 1.3 MB/s
Requirement already satisfied: jmespath in /usr/local/lib/python3.7/dist-packages (from azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (0.10.0)
Collecting adal~=1.2.7
Downloading adal-1.2.7-py2.py3-none-any.whl (55 kB)
|████████████████████████████████| 55 kB 904 kB/s
Collecting azure-cli-telemetry==1.0.6.*
Downloading azure_cli_telemetry-1.0.6-py3-none-any.whl (10 kB)
Collecting pkginfo>=1.5.0.1
Downloading pkginfo-1.8.2-py2.py3-none-any.whl (26 kB)
Collecting pyopenssl>=17.1.0
Downloading pyOpenSSL-21.0.0-py2.py3-none-any.whl (55 kB)
|████████████████████████████████| 55 kB 540 kB/s
Collecting cryptography<3.4,>=3.2
Downloading cryptography-3.3.2-cp36-abi3-manylinux2010_x86_64.whl (2.6 MB)
|████████████████████████████████| 2.6 MB 35.2 MB/s
Collecting msal<2.0.0,>=1.10.0
Downloading msal-1.16.0-py2.py3-none-any.whl (78 kB)
|████████████████████████████████| 78 kB 1.1 MB/s
Collecting urllib3[secure]>=1.26.5
Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
|████████████████████████████████| 138 kB 61.2 MB/s
Requirement already satisfied: six~=1.12 in /usr/lib/python3/dist-packages (from azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (1.12.0)
Collecting psutil~=5.8
Downloading psutil-5.9.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (280 kB)
|████████████████████████████████| 280 kB 51.5 MB/s
Collecting requests~=2.25.1
Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 1.2 MB/s
Requirement already satisfied: argcomplete~=1.8 in /usr/local/lib/python3.7/dist-packages (from azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (1.12.1)
Collecting knack~=0.8.2
Downloading knack-0.8.2-py3-none-any.whl (59 kB)
|████████████████████████████████| 59 kB 1.5 MB/s
Collecting azure-mgmt-core<1.3.0,>=1.2.0
Downloading azure_mgmt_core-1.2.2-py2.py3-none-any.whl (21 kB)
Collecting paramiko<3.0.0,>=2.0.8
Downloading paramiko-2.9.2-py2.py3-none-any.whl (210 kB)
|████████████████████████████████| 210 kB 56.8 MB/s
Collecting PyJWT>=2.1.0
Downloading PyJWT-2.3.0-py3-none-any.whl (16 kB)
Collecting msal-extensions~=0.3.0
Downloading msal_extensions-0.3.1-py2.py3-none-any.whl (18 kB)
Collecting azure-core<2.0.0,>=1.11.0
Downloading azure_core-1.21.1-py2.py3-none-any.whl (178 kB)
|████████████████████████████████| 178 kB 60.8 MB/s
Collecting azure-mgmt-datalake-nspkg>=2.0.0
Downloading azure_mgmt_datalake_nspkg-3.0.1-py3-none-any.whl (1.7 kB)
Requirement already satisfied: python-dateutil in /usr/local/lib/python3.7/dist-packages (from azure-storage==0.35.1->-r requirements-azure.txt (line 35)) (2.8.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from msrest==0.6.21->-r requirements-azure.txt (line 36)) (2020.6.20)
Requirement already satisfied: requests-oauthlib>=0.5.0 in /usr/local/lib/python3.7/dist-packages (from msrest==0.6.21->-r requirements-azure.txt (line 36)) (1.3.0)
Requirement already satisfied: isodate>=0.6.0 in /usr/local/lib/python3.7/dist-packages (from msrest==0.6.21->-r requirements-azure.txt (line 36)) (0.6.0)
Collecting portalocker~=1.2
Downloading portalocker-1.7.1-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: applicationinsights<0.12,>=0.11.1 in /usr/local/lib/python3.7/dist-packages (from azure-cli-telemetry==1.0.6.*->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (0.11.9)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./.local/lib/python3.7/site-packages (from packaging->-r requirements-azure.txt (line 1)) (3.0.7)
Collecting requests[security]
Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 440 kB/s
Downloading requests-2.27.0-py2.py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 424 kB/s
Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
|████████████████████████████████| 62 kB 216 kB/s
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests~=2.25.1->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (1.25.11)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests~=2.25.1->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests~=2.25.1->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (3.0.4)
Requirement already satisfied: importlib-metadata<3,>=0.23 in /usr/local/lib/python3.7/dist-packages (from argcomplete~=1.8->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (2.0.0)
Collecting azure-mgmt-datalake-nspkg>=2.0.0
Downloading azure_mgmt_datalake_nspkg-2.0.0-py2.py3-none-any.whl (3.0 kB)
Collecting cffi>=1.12
Downloading cffi-1.15.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (427 kB)
|████████████████████████████████| 427 kB 44.0 MB/s
Requirement already satisfied: colorama in /usr/local/lib/python3.7/dist-packages (from knack~=0.8.2->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (0.4.4)
Requirement already satisfied: tabulate in /usr/local/lib/python3.7/dist-packages (from knack~=0.8.2->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (0.8.7)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from knack~=0.8.2->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (5.3.1)
Requirement already satisfied: pygments in /usr/local/lib/python3.7/dist-packages (from knack~=0.8.2->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (2.7.2)
Requirement already satisfied: PyJWT[crypto]<3,>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from msal<2.0.0,>=1.10.0->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (1.7.1)
Collecting bcrypt>=3.1.3
Downloading bcrypt-3.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (61 kB)
|████████████████████████████████| 61 kB 119 kB/s
Collecting pynacl>=1.0.1
Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB)
|████████████████████████████████| 856 kB 39.6 MB/s
Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.5.0->msrest==0.6.21->-r requirements-azure.txt (line 36)) (3.1.0)
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
|████████████████████████████████| 118 kB 47.8 MB/s
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata<3,>=0.23->argcomplete~=1.8->azure-cli-core==2.26.1->-r requirements-azure.txt (line 4)) (3.4.0)
Installing collected packages: pycparser, urllib3, cffi, requests, PyJWT, cryptography, azure-nspkg, pyopenssl, pynacl, portalocker, msrest, msal, bcrypt, azure-mgmt-nspkg, azure-core, adal, psutil, pkginfo, paramiko, msal-extensions, knack, humanfriendly, azure-mgmt-datalake-nspkg, azure-mgmt-core, azure-common, azure-cli-telemetry, xmltodict, azure-storage, azure-mgmt-web, azure-mgmt-trafficmanager, azure-mgmt-storage, azure-mgmt-sql, azure-mgmt-servicebus, azure-mgmt-search, azure-mgmt-resource, azure-mgmt-redis, azure-mgmt-recoveryservicesbackup, azure-mgmt-recoveryservices, azure-mgmt-rdbms, azure-mgmt-privatedns, azure-mgmt-notificationhubs, azure-mgmt-network, azure-mgmt-monitor, azure-mgmt-marketplaceordering, azure-mgmt-managementgroups, azure-mgmt-managedservices, azure-mgmt-loganalytics, azure-mgmt-keyvault, azure-mgmt-iothub, azure-mgmt-hdinsight, azure-mgmt-eventhub, azure-mgmt-dns, azure-mgmt-devtestlabs, azure-mgmt-datalake-store, azure-mgmt-cosmosdb, azure-mgmt-containerservice, azure-mgmt-containerregistry, azure-mgmt-containerinstance, azure-mgmt-compute, azure-mgmt-cdn, azure-mgmt-batch, azure-mgmt-automation, azure-mgmt-authorization, azure-mgmt-apimanagement, azure-keyvault, azure-identity, azure-graphrbac, azure-cli-core
WARNING: The script pkginfo is installed in '/home/r_ota/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
WARNING: The script humanfriendly is installed in '/home/r_ota/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
sfctl 10.0.0 requires knack==0.6.3, but you have knack 0.8.2 which is incompatible.
Successfully installed PyJWT-2.3.0 adal-1.2.7 azure-cli-core-2.26.1 azure-cli-telemetry-1.0.6 azure-common-1.1.11 azure-core-1.21.1 azure-graphrbac-0.61.1 azure-identity-1.7.0 azure-keyvault-1.0.0a1 azure-mgmt-apimanagement-0.2.0 azure-mgmt-authorization-0.51.1 azure-mgmt-automation-0.1.1 azure-mgmt-batch-5.0.1 azure-mgmt-cdn-3.0.0 azure-mgmt-compute-10.0.0 azure-mgmt-containerinstance-1.4.0 azure-mgmt-containerregistry-2.0.0 azure-mgmt-containerservice-9.1.0 azure-mgmt-core-1.2.2 azure-mgmt-cosmosdb-0.5.2 azure-mgmt-datalake-nspkg-2.0.0 azure-mgmt-datalake-store-0.5.0 azure-mgmt-devtestlabs-3.0.0 azure-mgmt-dns-2.1.0 azure-mgmt-eventhub-2.0.0 azure-mgmt-hdinsight-0.1.0 azure-mgmt-iothub-0.7.0 azure-mgmt-keyvault-1.1.0 azure-mgmt-loganalytics-1.0.0 azure-mgmt-managedservices-1.0.0 azure-mgmt-managementgroups-0.2.0 azure-mgmt-marketplaceordering-0.1.0 azure-mgmt-monitor-3.0.0 azure-mgmt-network-12.0.0 azure-mgmt-notificationhubs-2.0.0azure-mgmt-nspkg-2.0.0 azure-mgmt-privatedns-0.1.0 azure-mgmt-rdbms-1.9.0 azure-mgmt-recoveryservices-0.4.0 azure-mgmt-recoveryservicesbackup-0.6.0 azure-mgmt-redis-5.0.0 azure-mgmt-resource-10.2.0 azure-mgmt-search-3.0.0 azure-mgmt-servicebus-0.5.3 azure-mgmt-sql-0.10.0 azure-mgmt-storage-11.1.0 azure-mgmt-trafficmanager-0.50.0 azure-mgmt-web-0.41.0 azure-nspkg-2.0.0 azure-storage-0.35.1 bcrypt-3.2.0 cffi-1.15.0 cryptography-3.3.2 humanfriendly-9.2 knack-0.8.2 msal-1.16.0 msal-extensions-0.3.1 msrest-0.6.21 paramiko-2.9.2 pkginfo-1.8.2 portalocker-1.7.1 psutil-5.9.0 pycparser-2.21 pynacl-1.5.0 pyopenssl-21.0.0 requests-2.25.1 urllib3-1.26.8 xmltodict-0.12.0
r_ota@Azure:~$
設定変更3(azure.azcollection追加)
実行
$ ansible-galaxy collection install azure.azcollection
結果
r_ota@Azure:~$ ansible-galaxy collection install azure.azcollection
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]. 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.
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/download/azure-azcollection-1.11.0.tar.gz to /home/r_ota/.ansible/tmp/ansible-local-43950wv8bqz/tmpl4qqt6x4/azure-azcollection-1.11.0-lnitcpts
Installing 'azure.azcollection:1.11.0' to '/home/r_ota/.ansible/collections/ansible_collections/azure/azcollection'
azure.azcollection:1.11.0 was installed successfully
r_ota@Azure:~$
設定後確認
実行
$ ansible --version
結果
r_ota@Azure:~$ ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]. 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.
ansible [core 2.11.7]
config file = None
configured module search path = ['/home/r_ota/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/r_ota/.local/lib/python3.7/site-packages/ansible
ansible collection location = /home/r_ota/.ansible/collections:/usr/share/ansible/collections
executable location = /home/r_ota/.local/bin/ansible
python version = 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
jinja version = 3.0.3
libyaml = False
r_ota@Azure:~$
設定後確認(playbook実行)
実行
$ ansible-playbook run.yml --extra-vars "importjson=./import.json" --check
結果
r_ota@Azure:~$ ansible-playbook run.yml --extra-vars "importjson=./import.json" --check
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]. 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'
PLAY [localhost] ****************************************************************************************************************************************************************************************************************************
TASK [Azure Security Group] *****************************************************************************************************************************************************************************************************************
TASK [az_securitygroup : Network Security group "r_ota-nsg_test1" Rule "AllowAzureStorageInbound" modify] ***********************************************************************************************************************************
ok: [localhost]
TASK [az_securitygroup : Network Security group "r_ota-nsg_test1" Rule "AllowAzureLoadBalancerInbound" modify] ******************************************************************************************************************************
ok: [localhost]
TASK [az_securitygroup : Network Security group "r_ota-nsg_test1" Rule "AllowClientInbound" modify] *****************************************************************************************************************************************
ok: [localhost]
TASK [az_securitygroup : Network Security group "r_ota-nsg_test2" Rule "AllowClientInbound" modify] *****************************************************************************************************************************************
ok: [localhost]
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
r_ota@Azure:~$
キタ━━━━(゚∀゚)━━━━!!
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]. 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.
とりあえず今回はここまで。。
メモ
その1
Cloud Shell で使用するストレージアカウント、下記命名規則なんだな。
csNNNNNNNNNNNNNNNNN
[cs(固定文字)]+[16進数19ケタ]
その2
Cloud Shellさん、初期起動直後は機嫌悪い時がある・・(同じ名前のコンテナを環境初期化するために消して→作成して→起動して やってたからかな。。
r_ota@Azure:~$ ansible --version
Unhandled error:
Traceback (most recent call last):
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 605, in update_config_data
value, origin = self.get_config_value_and_origin(config, configfile)
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 543, in get_config_value_and_origin
value = ensure_type(value, defs[config].get('type'), origin=origin)
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 124, in ensure_type
value = tempfile.mkdtemp(prefix=prefix, dir=value)
File "/usr/lib/python3.7/tempfile.py", line 505, in mkdtemp
_os.mkdir(file, 0o700)
OSError: [Errno 30] Read-only file system: '/home/r_ota/.ansible/tmp/ansible-local-301sip6wwns'
Traceback (most recent call last):
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 605, in update_config_data
value, origin = self.get_config_value_and_origin(config, configfile)
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 543, in get_config_value_and_origin
value = ensure_type(value, defs[config].get('type'), origin=origin)
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 124, in ensure_type
value = tempfile.mkdtemp(prefix=prefix, dir=value)
File "/usr/lib/python3.7/tempfile.py", line 505, in mkdtemp
_os.mkdir(file, 0o700)
OSError: [Errno 30] Read-only file system: '/home/r_ota/.ansible/tmp/ansible-local-301sip6wwns'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/r_ota/.local/bin/ansible", line 63, in <module>
import ansible.constants as C
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/constants.py", line 181, in <module>
config = ConfigManager()
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 310, in __init__
self.update_config_data()
File "/home/r_ota/.local/lib/python3.7/site-packages/ansible/config/manager.py", line 617, in update_config_data
raise AnsibleError("Invalid settings supplied for %s: %s\n" % (config, to_native(e)), orig_exc=e)
ansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: [Errno 30] Read-only file system: '/home/r_ota/.ansible/tmp/ansible-local-301sip6wwns'
. [Errno 30] Read-only file system: '/home/r_ota/.ansible/tmp/ansible-local-301sip6wwns'
r_ota@Azure:~$
Discussion