查看“RHCE8.0实训:实施多个PLAYBOOK”的源代码
←
RHCE8.0实训:实施多个PLAYBOOK
跳转至:
导航
,
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
==实训目的== 在本练习中,您将创建包含多个play的playbook,再用它来在受管主机上执行配置任务 ==实训步骤== 将目录更改到 0603 工作目录。 [student@workstation -]$ cd ~/0603 vi ansible.cfg: <nowiki> [defaults] inventory =hosts host_key_checking = False remote_user=maxin [privilege_escalation] become=True become_method=sudo become_user=root become_ask_pass=False </nowiki> vi inventory <nowiki>[master] localhost ansible_connection=local ansible_ssh_user=root 10.0.0.30 ansible_ssh_user=root [slave] 10.0.0.40 ansible_ssh_user=root </nowiki> 新建 playbook: intranet.yml <nowiki> --- - name: Enable intranet services hosts:slave become: yes tasks: - name: latest version of httpd and firewalld installed yum: name: - httpd - firewalld state: latest - name: test html page is installed copy: content: "Welcome to the example.com intranet!\n" dest: /var/www/html/index.html - name: firewalld enabled and running service: name: firewalld enabled: true state: started - name: firewalld permits access to httpd srevice firewalld: service: http permanent: true state: enabled immediate: yes - name: httpd enabled and running service: name: httpd enabled: true state: started - name: Testintranet web server hosts: localhost become: no tasks: - name: connect to intranet web server uri: url: http://10.0.0.40 return_content: yes status_code: 200 </nowiki> ===语法验证=== [root@localhost playbook-multi]# ansible-playbook --syntax-check intranet.yml <nowiki>[DEPRECATION WARNING]: The firewalld module has been moved to the ansible.posix collection. This feature will be removed from community.general in version 2.0.0. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. playbook: intranet.yml </nowiki> ===执行play=== ansible-playbook intranet.yml <nowiki> PLAY [Testintranet web server] ************************************************* TASK [Gathering Facts] ********************************************************* ok: [localhost] TASK [connect to intranet web server] ****************************************** ok: [localhost] => {"accept_ranges": "bytes", "changed": false, "connection": "close", "content": " <!doctype html>\n <html>\n <head>\n <meta charset=\"utf-8\" />\n <title>我的第一个 HTML 页面</title>\n </head>\n\n <body>\n <h2>我的第一个网页</h2>\n <p>这是我的第一个网页</p>\n <p>这是我的第一个网页,虽然很简单,但是很有意义。</p>\n </body>\n </html>\n", "content_length": "358", "content_type": "text/html; charset=UTF-8", "cookies": {}, "cookies_string": "", "date": "Sun, 14 Feb 2021 07:19:43 GMT", "elapsed": 0, "etag": "\"166-5bb355c0386ad\"", "last_modified": "Sat, 13 Feb 2021 10:38:54 GMT", "msg": "OK (358 bytes)", "redirected": false, "server": "Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9", "status": 200, "url": "http://10.0.0.30"} PLAY RECAP ********************************************************************* localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 </nowiki>
返回至
RHCE8.0实训:实施多个PLAYBOOK
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息