首页 > 代码库 > ansible-playbook使用示例参考
ansible-playbook使用示例参考
ansible-playbook参考
(1)基础示例
~]# vim base.yaml - hosts: 192.168.1.114 remote_user: root tasks: - name: install httpd server yum: name=httpd state=present - name: start httpd server service: name=httpd state=started
(2)handlers示例
~]# vim handlers.yaml - hosts: 192.168.1.114 remote_user: root tasks: - name: install httpd yum: name=httpd state=present - name: install configure file copy: src=http://www.mamicode.com/file/httpd.conf dest=/etc/httpd/conf/httpd.conf>(3)tags示例
~]# vim tags.yaml - hosts: 192.168.1.114 remote_user: root tasks: - name: install httpd yum: name=httpd state=present - name: install configure file copy: src=http://www.mamicode.com/file/httpd.conf dest=/etc/httpd/conf/httpd.conf>(4)variables示例
~]# vim variables.yaml - hosts: 192.168.1.114 remote_user: root tasks: - name: install {{ package }} yum: name={{ package }} state=present a. 直接通过fact调用,使用setup模块可以获取 b. ~]# ansible-playbook variables.yaml -e package=httpd c. ~]# vim /etc/ansible/hosts [websrvs] 192.168.1.114 package=httpd ~]# ansible-playbook variables.yaml
ansible-playbook使用示例参考
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。