红帽RHCE之Ansible-7-playbook综合实验

Ansible-7-playbook综合实验

//开始练习
[student@workstation ~]$ lab playbook-review start

Starting the lab on :

 · Verifying Ansible installation..............................  SUCCESS
 · Creating working directory..................................  SUCCESS
 · Deploying Ansible inventory.................................  SUCCESS
 · Deploying ansible.cfg.......................................  SUCCESS

[student@workstation ~]$ cd playbook-review/
[student@workstation playbook-review]$ ls
ansible.cfg  inventory
[student@workstation playbook-review]$ cat ansible.cfg 
[defaults]
inventory=inventory
remote_user=devops

[privilege_escalation]
become=False
become_method=sudo
become_user=root
become_ask_pass=False
[student@workstation playbook-review]$ cat inventory 
serverb.lab.example.com

[student@workstation playbook-review]$ ls
ansible.cfg  internet.yml  inventory
[student@workstation playbook-review]$ cat internet.yml 
---
- name: Enable internet services
  hosts: serverb.lab.example.com
  become: yes 
  tasks:
          - name: Install the latest versions of firewall, mariadb-server, php, and php-mysqlnd package
            yum:
                    name:
                            - httpd
                            - firewalld
                            - mariadb-server
                            - php
                            - php-mysqlnd
                    state: latest
          - name: firewalld enabled and running
            service:
                    name: firewalld
                    state: started
                    enabled: true
          - name: firewalld access is allowed to the httpd service
            firewalld:
                    service: http
                    permanent: true
                    state: enabled
                    immediate: yes 
          - name: httpd enabled and running
            service:
                    name: httpd
                    state: started
                    enabled: true
          - name: mariadb enabled and running
            service:
                    name: mariadb
                    state: started
                    enabled: true
          - name: get_url get index html file
            get_url:
                    url: http://materials.example.com/labs/playbook-review/index.php
                    dest: /var/www/html


- name: connection test
  hosts: localhost
  become: no
  tasks:
          - name: connection to internet web server
            uri:
                    url: http://serverb.lab.example.com
                    return_content: yes
                    status_code: 200



[student@workstation playbook-review]$ ansible-playbook internet.yml 

PLAY [Enable internet services] ***********************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************
ok: [serverb.lab.example.com]

TASK [Install the latest versions of firewall, mariadb-server, php, and php-mysqlnd package] **********************************************************************************************************************************
ok: [serverb.lab.example.com]

TASK [firewalld enabled and running] ******************************************************************************************************************************************************************************************
ok: [serverb.lab.example.com]

TASK [firewalld access is allowed to the httpd service] ***********************************************************************************************************************************************************************
ok: [serverb.lab.example.com]

TASK [httpd enabled and running] **********************************************************************************************************************************************************************************************
ok: [serverb.lab.example.com]

TASK [mariadb enabled and running] ********************************************************************************************************************************************************************************************
changed: [serverb.lab.example.com]

TASK [get_url get index html file] ********************************************************************************************************************************************************************************************
changed: [serverb.lab.example.com]

PLAY [connection test] ********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [connection to internet web server] **************************************************************************************************************************************************************************************
ok: [localhost]

PLAY RECAP ********************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
serverb.lab.example.com    : ok=7    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[student@workstation playbook-review]$ lab playbook-review grade

Grading the student's work on serverb:

 · Verify httpd package installation...........................  PASS
 · Verify firewalld package installation.......................  PASS
 · Verify mariadb-server package installation..................  PASS
 · Verify php package installation.............................  PASS
 · Verify php-mysqlnd package installation.....................  PASS
 · Verify httpd service........................................  PASS
 · Verify firewalld service....................................  PASS
 · Verify mariadb service......................................  PASS
 · Verify firewalld configuration..............................  PASS
 · Verify web site.............................................  PASS
Overall lab grade..............................................  PASS
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值