我創建了以下劇本來創建 vultr 機器。我正在使用ansible的vultr模組並放置了所有必要的參數;
---
# Ansible Blocks
- hosts: 127.0.0.1
# gather_facts: False
connection: local
tasks:
- block:
- name: List root
local_action:
module: vr_server
name: "myserver"
os: CentOS 7 x64
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
region: Amsterdam
api_key: "242HXXXXXXC3HGGXPSZTK7ILY4QUEC5KN555"
api_account: "john"
rescue:
- name: Only run when a task inside the block throws an error.
debug: msg="Something went wrong."
always:
- name: Always run.
debug: msg="Regardless of what happened above, we're done with this block!"
...
但是當我運行它時,我收到以下錯誤:
fatal: [127.0.0.1 -> localhost]: FAILED! => {"changed": false, "msg": "Config file not found. Tried : /home/john/.vultr.ini, /home/john/automation/utils/ansible-vultr/core_vultr/vultr.ini"}
看起來,它正在搜尋 vultr.ini。為什麼會這樣呢?我應該在 vultr.ini 檔案中放入什麼?
Ansible 的版本是 2.5.0,運行在 ubuntu 14.04 上。
答案1
看起來這個連結可能正是您正在尋找的內容:https://www.renemoser.net/blog/2018/03/18/begin-vultr-with-ansible/
具體來說,您可能需要這一點:
[default]
key = <your api key>