红帽RHCE之Ansible-6-playbook实验

Ansible-6-playbook实验

//开始实验
[student@workstation ~]$ lab playbook-basic start

Setting up workstation for lab exercise work:

 · Verifying Ansible installation..............................  SUCCESS
 · Creating working directory..................................  SUCCESS
 · Deploying Ansible inventory.................................  SUCCESS
 · Deploying ansible.cfg.......................................  SUCCESS
 · Downloading index.html......................................  SUCCESS
 · Stop firewalld on serverc...................................  SUCCESS
 · Stop firewalld on serverd...................................  SUCCESS

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

[privilege_escalation]
become=True
become_method=sudo
become_user=root
become_ask_pass=False
[student@workstation playbook-basic]$ cat inventory 
[web]
serverc.lab.example.com
serverd.lab.example.com

[student@workstation playbook-basic]$ ansible-playbook site.yml 

PLAY [Install and start Apache HTTPD] *****************************************************************************************************************************************************************************************

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

TASK [httpd package is present] ***********************************************************************************************************************************************************************************************
ok: [serverc.lab.example.com]
ok: [serverd.lab.example.com]

TASK [correct index.html is present] ******************************************************************************************************************************************************************************************
ok: [serverd.lab.example.com]
ok: [serverc.lab.example.com]

TASK [start httpd] ************************************************************************************************************************************************************************************************************
changed: [serverc.lab.example.com]
changed: [serverd.lab.example.com]

PLAY RECAP ********************************************************************************************************************************************************************************************************************
serverc.lab.example.com    : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
serverd.lab.example.com    : ok=4    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[student@workstation playbook-basic]$ curl serverc
This is a test page.
[student@workstation playbook-basic]$ curl serverd
This is a test page.
[student@workstation playbook-basic]$ cat inventory 
[web]
serverc.lab.example.com
serverd.lab.example.com  

[student@workstation playbook-basic]$ cat site.yml 
---
- name: Install and start Apache HTTPD
  hosts: web
  tasks:
          - name: httpd package is present
            yum:
                    name: httpd
                    state: present
          - name: correct index.html is present
            copy:
                    src: files/index.html
                    dest: /var/www/html/index.html

//完成
[student@workstation playbook-basic]$ lab playbook-basic finish

Cleaning up exercise

 · Remove web content..........................................  SUCCESS
 · Remove httpd package........................................  SUCCESS
 · Start firewalld on serverc..................................  SUCCESS
 · Start firewalld on serverd..................................  SUCCESS
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值