是否有方法调用服务端点中的terraform部署实用程序(快速a、烧瓶)
总结服务端点与Terraform的集成?
发布于 2022-04-26 06:27:41
在对它进行了一些探索之后,观察到没有这样的直接模块可以使用,所以我已经找到了一种以路由方式使用它的方法。以下是可以使用的步骤:
1>使用模板在aws上部署
2>调用可调用的游戏手册
---
- hosts: localhost
become: no
gather_facts: False
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: Deployment CFT via terraform for aws infra
community.general.terraform:
project_path: '/root/terraform-sample-ansible'
state: present
3>只适用于游戏手册,我们可以使用terraform模块。
4>在ansible剧本中编写了一种方法,在部署后将json输出转储到某个文件
5>现在编写服务端点代码,比如使用endpoint.py
片段:
@app.get("/")
async def get_instances():
""" REST endpoint to query instances """
play_run = run_playbook(playbook='<path of ansible file>')
with open("<file where output of ansible is dumped>", "r") as read_file:
data = json.load(read_file)
pretty_json = json.dumps(data, indent=4)
print(pretty_json)
return data
这可能是terraform,ansible和服务端点( endpoint )的集成。
谢谢!
https://stackoverflow.com/questions/71712484
复制相似问题