问题描述
来自MS Azure网站的
This官方文档Quickstart: Configure Ansible using Azure Cloud Shell
,要求您首先将以下代码另存为create_rg.yml
,然后运行ansible-playbook
命令(如第二个代码所示)在下面的代码中)。
问题:运行命令之前,create_rg.yml
会保存在哪里(如下面的第二个代码块所示)?
create_rg.yml文件:
---
- hosts: localhost
connection: local
tasks:
- name: Creating resource group - "{{ name }}"
azure_rm_resourcegroup:
name: "{{ name }}"
location: "{{ location }}"
register: rg
- debug:
var: rg
ansible-playbook命令以运行Azure Cloud Shell :
ansible-playbook create_rg.yml --extra-vars "name=<resource_group_name> location=<resource_group_location>"
备注:当我在本地文件夹中将create_rg.yml文件另存为C:\TestFolder\create_rg.yml
时,上述命令给出以下错误:
错误!剧本:C:\ TestFolder \ create_rg.yml找不到
解决方法
您可以将.yml
文件保存到PowerShell中的目录/home/nancy
或Azure Cloud Shell中的Bash中,而不是本地文件夹中。有一个内置的tool in Azure cloud Shell。