DO447利用推荐做法进行开发--章节实验

简介: DO447利用推荐做法进行开发--章节实验

DO447利用推荐做法进行开发–章节实验

RHCSA专栏:戏说 RHCSA 认证

RHCE专栏:戏说 RHCE 认证

此文章(第一章 利用推荐做法进行开发–章节实验 )收录在RHCA专栏:RHCA 回忆录

[student@workstation ~]$ lab development-review start


📑按要求拉取代码并进入代码目录

[student@workstation ~]$ cd git-repos
[student@workstation git-repos]$ git clone http://git.lab.example.com:8081/git/development-review.git
Cloning into 'development-review'...
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 53 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (53/53), done.
[student@workstation git-repos]$ cd development-review

📑验证代码剧本准确性

[student@workstation development-review]$ ansible-playbook site.yml
[student@workstation development-review]$ curl http://servera
This is serverb.lab.example.com. (version v1.0)
[student@workstation development-review]$ curl http://servera
This is serverc.lab.example.com. (version v1.0)
[student@workstation development-review]$ curl http://servera
This is serverb.lab.example.com. (version v1.0)
[student@workstation development-review]$ curl http://servera
This is serverc.lab.example.com. (version v1.0)

📑修改角色目录名称

[student@workstation development-review]$ cd roles/
[student@workstation roles]$ ls
firewall  haproxy  my_role  webapp
[student@workstation roles]$ mv -v my_role apache
renamed 'my_role' -> 'apache'
[student@workstation roles]$ cd ..

[student@workstation development-review]$ vim deploy_apache.yml 
- name: Ensure Apache is deployed
  hosts: web_servers
  force_handlers: True
  gather_facts: no

  roles:
    # The "apache" role has a dependency
    # on the "firewall" role. The
    # "firewall" role requires a
    # "firewall_rules" variable be defined.
    - role: apache
      firewall_rules:

        # Allow http requests from the
        # internal zone.
        - zone: internal
          service: http

        # Add the load balancer IP to
        # the internal zone.
        - zone: internal
          source: 172.25.250.10
# 可使用 %s#my_role#apache#g 进行查找替换

📑运行测试

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

📑提交改变的代码

[student@workstation development-review]$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   deploy_apache.yml
    deleted:    roles/my_role/meta/main.yml
    deleted:    roles/my_role/tasks/main.yml
    deleted:    roles/my_role/vars/main.yml

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    roles/apache/

no changes added to commit (use "git add" and/or "git commit -a")

[student@workstation development-review]$ git rm roles/my_role/*
rm 'roles/my_role/meta/main.yml'
rm 'roles/my_role/tasks/main.yml'
rm 'roles/my_role/vars/main.yml'
[student@workstation development-review]$ git add roles/apache
[student@workstation development-review]$ git add deploy_apache.yml
[student@workstation development-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)

    modified:   deploy_apache.yml
    renamed:    roles/my_role/meta/main.yml -> roles/apache/meta/main.yml
    renamed:    roles/my_role/tasks/main.yml -> roles/apache/tasks/main.yml
    renamed:    roles/my_role/vars/main.yml -> roles/apache/vars/main.yml

[student@workstation development-review]$ git commit -m "Renamed my_role role to apache."
[master ad25d92] Renamed my_role role to apache.
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename roles/{
    my_role => apache}/meta/main.yml (100%)
 rename roles/{
    my_role => apache}/tasks/main.yml (100%)
 rename roles/{
    my_role => apache}/vars/main.yml (100%)
[student@workstation development-review]$ git push
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 392 bytes | 392.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0)
To http://git.lab.example.com:8081/git/development-review.git
   19d8b5e..ad25d92  master -> master

📑完善剧本的要素

[student@workstation development-review]$ cat deploy_webapp.yml 
- name: Ensure the web application is deployed
  hosts: web_servers
  gather_facts: no
  vars:
    version: v1.0
    message: "This is {
    { inventory_hostname }}."

  roles:
    - role: webapp
[student@workstation development-review]$ cat roles/webapp/tasks/main.yml 
---
# tasks file for webapp

- name: Ensure placeholder content is deployed
  copy:
    content: "{
    { message }} (version {
    { version }})\n"
    dest: /var/www/html/index.html

📑运行测试

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

📑提交改变的代码

[student@workstation development-review]$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   deploy_webapp.yml
    modified:   roles/webapp/tasks/main.yml

no changes added to commit (use "git add" and/or "git commit -a")
[student@workstation development-review]$ git add deploy_webapp.yml
[student@workstation development-review]$ git add roles/webapp/*
[student@workstation development-review]$ git commit -m "Added names to webapp playbook and role."
[master 5145179] Added names to webapp playbook and role.
 2 files changed, 4 insertions(+), 2 deletions(-)
[student@workstation development-review]$ git push
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 753 bytes | 753.00 KiB/s, done.
Total 7 (delta 3), reused 0 (delta 0)
To http://git.lab.example.com:8081/git/development-review.git
   ad25d92..5145179  master -> master

📑按要求修改变量名称

[student@workstation development-review]$ cat roles/webapp/tasks/main.yml 
---
# tasks file for webapp

- name: Ensure placeholder content is deployed
  copy:
    content: "{
    { webapp_message }} (version {
    { webapp_version }})\n"
    dest: /var/www/html/index.html
[student@workstation development-review]$ cat roles/webapp/defaults/main.yml 
webapp_version: v1.0
webapp_message: "This is {
    { inventory_hostname }}."
[student@workstation development-review]$ cat deploy_webapp.yml 
- name: Ensure the web application is deployed
  hosts: web_servers
  gather_facts: no
  vars:
    webapp_version: v1.0
    webapp_message: "This is {
    { inventory_hostname }}."

  roles:
    - role: webapp

📑运行测试

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

📑提交改变的代码

[student@workstation development-review]$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   deploy_webapp.yml
    modified:   roles/webapp/defaults/main.yml
    modified:   roles/webapp/tasks/main.yml

no changes added to commit (use "git add" and/or "git commit -a")
[student@workstation development-review]$ git add deploy_webapp.yml
[student@workstation development-review]$ git add roles/webapp/*
[student@workstation development-review]$ git commit -m "Updated webapp role variable names."
[master 30ee0ab] Updated webapp role variable names.
 3 files changed, 5 insertions(+), 5 deletions(-)
[student@workstation development-review]$ git push
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 790 bytes | 790.00 KiB/s, done.
Total 9 (delta 4), reused 0 (delta 0)
To http://git.lab.example.com:8081/git/development-review.git
   5145179..30ee0ab  master -> master

📑再次运行总测试

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

📑评分并清除实验

[student@workstation development-review]$ lab development-review grade
[student@workstation development-review]$ lab development-review finish

💡总结

RHCA认证经历5门的考试,还是需要花不少时间去学习与备考的,好好加油,可以噶🤪。

以上就是【金鱼哥】对 第一章 利用推荐做法进行开发–章节实验 的简述和讲解。希望能对看到此文章的小伙伴有所帮助。

如果这篇【文章】有帮助到你,希望可以给【金鱼哥】点个赞👍,创作不易,相比官方的陈述,我更喜欢用【通俗易懂】的文笔去讲解每一个知识点,如果有对【运维技术】感兴趣,也欢迎关注❤️❤️❤️ 【金鱼哥】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】💕💕!

目录
相关文章
|
存储 编译器 C#
C#基础补充
C#基础补充
64 0
|
5月前
|
编译器 C++
《Effective C++ 改善程序与设计的55个具体做法》 第一章 笔记
《Effective C++ 改善程序与设计的55个具体做法》 第一章 笔记
|
6月前
|
网络协议 Linux 网络安全
实验内容参考
实验内容参考
36 0
|
Ubuntu Unix Linux
进程章节总结性实验
进程章节总结性实验
32 0
|
存储 缓存 网络协议
[计算机网络(第八版)]第一章 概述(章节测试 + 章节作业 + 答案解析)
[计算机网络(第八版)]第一章 概述(章节测试 + 章节作业 + 答案解析)
|
算法 Java 测试技术
我的算法基础实验代码-下篇
算法题目,Java语言版
76 0
|
JavaScript 前端开发
技术汇总:第七章:三种验证方式
技术汇总:第七章:三种验证方式
133 0
技术汇总:第七章:三种验证方式
分体式测斜探头安装注意要点
分体式测斜探头采用高端 MEMS 技术的双轴高精度倾角仪,主要用于坝体、边坡、路基、基坑、岩体滑坡及大型建筑倾斜、土体内部水平位移变形测量。该仪器可重复使用,并可方便地实现倾斜测量的自动化监测。产品安装方便、使用简单、抗外界电磁干扰、承受振动冲击能力强,是军工装备、工业自动化、测量测绘等行业倾角测量的最佳选择。
分体式测斜探头安装注意要点
|
数据采集 监控 数据可视化
功能介绍补充|学习笔记
快速学习功能介绍补充
功能介绍补充|学习笔记
下一篇
无影云桌面