Ansible === ###### tags: `Data Center` `QCT` `Auto-Deployment` `IBM` ## Install RHEL 7 ``` subscription-manager repos --enable rhel-7-server-ansible-2.9-rpms yum install ansible ``` ## CLI - [手把手教你在python中運行ansible-playbook](https://www.twblogs.net/a/5d0a5bd8bd9eee1ede03fb04) - [ansible/lib/ansible/cli](https://github.com/ansible/ansible/tree/devel/lib/ansible/cli) ``` ansible-playbook -i 10.103.3.101, playbook.yml --extra-vars "ansible_ssh_common_args='-o StrictHostKeyChecking=no' ansible_ssh_user=root ansible_ssh_pass=cmb9.admin dc_id=1 room_id=2 rack_id=3 bmc_account=admin bmc_pass=cmb9.admin bmc_ip=10.103.15.13 rhel_account=AbbyWu rhel_pass=cmb9.admin" -vvv ``` ``` # playbook.yml --- - name: simple playbook gather_facts: no hosts: all remote_user: root become: True become_method: sudo tasks: - name: list files or directories shell: ls ``` ## Python API :::danger This API is intended for internal Ansible use. Ansible may make changes to this API at any time that could break backward compatibility with older versions of the API. Because of this, external use is not supported by Ansible. ::: - [Python API example](https://docs.ansible.com/ansible/latest/dev_guide/developing_api.html#python-api-2-0) - [Ansible API 开发](https://www.jianshu.com/p/ec1e4d8438e9) - [如何使用Ansible 2 的API做python开发](https://www.jianshu.com/p/8558befb16c1)