IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> 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门的考试,还是需要花不少时间去学习与备考的,好好加油,可以噶🤪。

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

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

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-04-06 23:24:56  更:2022-04-06 23:25:13 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 5:22:48-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码