金鱼哥RHCA回忆录:DO447管理清单--章节实验
【摘要】 第二章 管理清单--章节实验
🎹 个人简介:大家好,我是 金鱼哥,CSDN运维领域新星创作者,华为云·云享专家,阿里云社区·专家博主
📚个人资质:CCNA、HCNP、CSNA(网络分析师),软考初级、中级网络工程师、RHCSA、RHCE、RHCA、RHCI、ITIL😜
💬格言:努力不一定成功,但要想成功就必须努力🔥
[student@workstation ~]$ lab inventory-review start
📑拉取实验代码
[student@workstation ~]$ cd git-repos/
[student@workstation git-repos]$ git clone http://git.lab.example.com:8081/git/inventory-review.git
Cloning into 'inventory-review'...
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 56 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (56/56), done.
[student@workstation git-repos]$ cd inventory-review
📑运行剧本并验证
[student@workstation inventory-review]$ cat inventory
[lb_servers]
servera.lab.example.com
[web_servers]
[web_servers:children]
a_web_servers
b_web_servers
# Group "A" of Web Servers
[a_web_servers]
serverb.lab.example.com
# Group "B" of Web Servers
[b_web_servers]
serverc.lab.example.com
[student@workstation inventory-review]$ ansible-playbook site.yml
[student@workstation inventory-review]$ curl http://servera
Hello from serverb.lab.example.com. (version v1.1)
[student@workstation inventory-review]$ curl http://servera
Hello from serverc.lab.example.com. (version v1.1)
📑按要求创建主机组变量
[student@workstation inventory-review]$ mkdir -pv group_vars/{a,b}_web_servers
mkdir: created directory 'group_vars/a_web_servers'
mkdir: created directory 'group_vars/b_web_servers'
[student@workstation inventory-review]$ echo "webapp_version: v1.1a" > group_vars/a_web_servers/webapp.yml
[student@workstation inventory-review]$ echo "webapp_version: v1.1b" > group_vars/b_web_servers/webapp.yml
📑运行剧本并验证
[student@workstation inventory-review]$ ansible-playbook deploy_webapp.yml
[student@workstation inventory-review]$ curl http://servera
Hello from serverb.lab.example.com. (version v1.1a)
[student@workstation inventory-review]$ curl http://servera
Hello from serverc.lab.example.com. (version v1.1b)
📑提交修改到工作区
[student@workstation inventory-review]$ git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
group_vars/a_web_servers/
group_vars/b_web_servers/
nothing added to commit but untracked files present (use "git add" to track)
[student@workstation inventory-review]$ git add group_vars/{a,b}_web_servers
[student@workstation inventory-review]$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: group_vars/a_web_servers/webapp.yml
new file: group_vars/b_web_servers/webapp.yml
[student@workstation inventory-review]$ git commit -m "Created variable files for the A and B groups."
[master 05c2080] Created variable files for the A and B groups.
2 files changed, 2 insertions(+)
create mode 100644 group_vars/a_web_servers/webapp.yml
create mode 100644 group_vars/b_web_servers/webapp.yml
📑编写yaml清单文件并测试执行
[student@workstation inventory-review]$ cat inventory.yml
lb_servers:
hosts:
servera.lab.example.com:
web_servers:
children:
a_web_servers:
hosts:
serverb.lab.example.com:
b_web_servers:
hosts:
serverc.lab.example.com:
[student@workstation inventory-review]$ ansible-playbook site.yml -i inventory.yml
📑改写为变量识别主机并测试运行
[student@workstation inventory-review]$ cat inventory.yml
lb_servers:
hosts:
loadbalancer_1:
ansible_host: servera.lab.example.com
web_servers:
children:
a_web_servers:
hosts:
backend_a1:
ansible_host: serverb.lab.example.com
b_web_servers:
hosts:
backend_b1:
ansible_host: serverc.lab.example.com
[student@workstation inventory-review]$ ansible-playbook site.yml -i inventory.yml
📑提交修改后的代码项目
[student@workstation inventory-review]$ git add inventory.yml
[student@workstation inventory-review]$ git commit -m "Added YAML inventory"
[master 3fc697d] Added YAML inventory
1 file changed, 15 insertions(+)
create mode 100644 inventory.yml
[student@workstation inventory-review]$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
[student@workstation inventory-review]$ git push
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (10/10), 920 bytes | 920.00 KiB/s, done.
Total 10 (delta 2), reused 0 (delta 0)
To http://git.lab.example.com:8081/git/inventory-review.git
e1de24a..3fc697d master -> master
📑评测与清除实验
[student@workstation inventory-review]$ lab inventory-review grade
[student@workstation inventory-review]$ lab inventory-review finish
💡总结
RHCA认证需要经历5门的学习与考试,还是需要花不少时间去学习与备考的,好好加油,可以噶🤪。
以上就是【金鱼哥】对 第二章 管理清单–章节实验 的简述和讲解。希望能对看到此文章的小伙伴有所帮助。
💾红帽认证专栏系列:
RHCSA专栏:戏说 RHCSA 认证
RHCE专栏:戏说 RHCE 认证
此文章收录在RHCA专栏:RHCA 回忆录
如果这篇【文章】有帮助到你,希望可以给【金鱼哥】点个赞👍,创作不易,相比官方的陈述,我更喜欢用【通俗易懂】的文笔去讲解每一个知识点。
如果有对【运维技术】感兴趣,也欢迎关注❤️❤️❤️ 【金鱼哥】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】💕💕!
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)