ansible的调用使用

ansile文档

 

英文文档:

https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html#common-options

 

中文文档:

https://ansible-book.gitbooks.io/ansible-first-book/

 

 

操作模块文档:

 

http://www.zsythink.net/archives/2542/

 

https://blog.csdn.net/lcl_xiaowugui/article/details/81878345

 

https://www.cnblogs.com/kevincaptain/p/10001174.html

 

 

模块调用


 

1、shell模块调用

如,ansible testhost -m shell -a "/bin/bash opt/test.sh"

 

注意:调用的时候不会将path环境变量带过去,所有命令要写环境变量的命令,以及脚本里面的路径,不能写相对路径

 

转载于:https://www.cnblogs.com/qiangyuzhou/articles/10493946.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Ansible调用OpenStack API下载镜像,需要使用以下步骤: 1. 安装python-openstackclient和python-novaclient: ``` $ sudo pip install python-openstackclient python-novaclient ``` 2. 创建一个名为“download_image.yaml”的YAML文件,并在其中定义以下Playbook: ```yaml - hosts: localhost gather_facts: no tasks: - name: Download image os_compute_api: auth: auth_url: "{{ auth_url }}" username: "{{ username }}" password: "{{ password }}" project_name: "{{ project_name }}" project_domain_name: "{{ project_domain_name }}" user_domain_name: "{{ user_domain_name }}" api_version: 2 endpoint_type: public service_name: compute resource: servers server: "{{ server_name }}" action: image.create image_name: "{{ image_name }}" disk_format: "{{ disk_format }}" container_format: "{{ container_format }}" ``` 3. 在上面的Playbook中,将以下变量替换为OpenStack API的凭据和要下载的镜像的详细信息: ``` auth_url: OpenStack API的认证URL username: OpenStack API的用户名 password: OpenStack API的密码 project_name: OpenStack API的项目名称 project_domain_name: OpenStack API的项目域名 user_domain_name: OpenStack API的用户域名 server_name: 要下载镜像的实例名称 image_name: 要下载的镜像名称 disk_format: 镜像的磁盘格式(例如qcow2) container_format: 镜像的容器格式(例如bare) ``` 4. 运行以下命令以使用上述Playbook: ``` $ ansible-playbook download_image.yaml ``` 这将调用OpenStack API并下载指定的镜像。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值