我正在尝试ansible
来处理GCP resources
。最初,我尝试使用GCP storage bucket
创建一个ansible
。为此,我使用以下命令在ansible
中安装了GCP CLoud Shell
。还创建了一个service account
并生成了基于JSON的密钥文件。
sudo apt-get install ansible
还使用以下命令安装了gcloud模块
sudo pip3 install google.cloud
现在我正尝试使用下面的Storage bucket
文件创建一个YAML
- name: create a bucket
tasks:
- name: Storage bucket
google.cloud.gcp_storage_bucket:
name: ansible-storage-module
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.json"
state: present
但是当我运行ansible-playbook
ansible-playbook ansible.yaml
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/home/project/ansible/ansible.yaml': line 4, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
违规行似乎是:
- name: Storage bucket
^ here
答案 0 :(得分:2)
我通过使用Ansible
安装google-auth
和pip
来解决此问题。
pip install ansible
pip install requests google-auth
对playbook
进行了一些修改以使其正常工作
- name: create a bucket
hosts: localhost
tasks:
- name: Storage bucket
google.cloud.gcp_storage_bucket:
name: ansible-storage-module
project: adminproject-272208
auth_kind: serviceaccount
service_account_file: "/home/project/ansible/project.json"
state: present
gsutil
显示存储桶已创建
$ gsutil ls
gs://ansible-storage-module/