From f63715c00188db5075f0d132dd568b5f0067039b Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 13 Oct 2016 23:33:29 +0800 Subject: [PATCH] =?UTF-8?q?PUB:20161010=20Antergos=20=E2=80=93=20Best=20Ar?= =?UTF-8?q?ch=20based=20distro=20for=20beginners?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @bestony --- ... with Atomic Host, Ansible, and Cockpit.md | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/translated/tech/20161007 Deploy containers with Atomic Host, Ansible, and Cockpit.md b/translated/tech/20161007 Deploy containers with Atomic Host, Ansible, and Cockpit.md index 67531dc0a1..f0d3dcb523 100644 --- a/translated/tech/20161007 Deploy containers with Atomic Host, Ansible, and Cockpit.md +++ b/translated/tech/20161007 Deploy containers with Atomic Host, Ansible, and Cockpit.md @@ -1,35 +1,41 @@ -# 使用Atomic Host,Ansible和Cockpit部署容器 +使用原子主机(Atomic Host)、Ansible 和 Cockpit 部署容器 +============== ![atomic-ansible-cockpit-containers](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/atomic-ansible-cockpit-containers.jpg?fit=945%2C400&ssl=1) -在我在[红帽](https://www.redhat.com/)工作的过程中, 我每天在 [Fedora Atomic host](https://getfedora.org/en/cloud/download/atomic.html) 上使用 [Docker](https://www.docker.com/). 来自[Project Atomic](http://www.projectatomic.io/)的Atomic Host是一个轻量级容器操作系统,可以以Docker格式运行Linux容器。它为提高效率被修改,使其成为用于云环境的Docker运行时系统的最佳选择。 +我在[红帽](https://www.redhat.com/)工作的期间,每天在 [Fedora Atomic host](https://getfedora.org/en/cloud/download/atomic.html) 上使用 [Docker](https://www.docker.com/) 容器。 来自 [原子项目(Project Atomic)](http://www.projectatomic.io/)的原子主机(Atomic Host)是一个轻量级容器操作系统,可以以 Docker 格式运行 Linux 容器。它专门为提高效率而定制,使其成为用于云环境的 Docker 运行时系统的理想选择。 -幸运的是,我发现一个很好的方式来管理在主机上运行的容器: [Cockpit](http://cockpit-project.org/). Cockpit是一个具有漂亮的Web UI的GNU / Linux服务器的远程管理器。它帮我管理在主机上运行的服务器和容器。你可以看更多的关于Cockpit在之前发布的 [这篇导览文](https://fedoramagazine.org/cockpit-overview/)  但是,我也想在主机上自动运行容器,我已经使用 [Ansible](https://www.ansible.com/). +幸运的是,我发现一个很好的方式来管理在主机上运行的容器:[Cockpit](http://cockpit-project.org/)。 它是一个具有漂亮的 Web 界面的 GNU/Linux 服务器远程管理工具。它可以帮我管理在主机上运行的服务器和容器。你可以在从之前发布在这里的[这篇概述](https://fedoramagazine.org/cockpit-overview/)中了解 Cockpit 的更多信息。不过,我也希望在主机上可以自动运行容器,我可以使用 [Ansible](https://www.ansible.com/) 来完成这个工作。 -请注意,我们不能在Atomic主机上使用dnf命令。主机不是设计为通用操作系统,而是更适合容器和其他目的。但在Atomic主机上设置应用程序和服务仍然非常容易。这篇文章向您展示了如何自动化和简化这个过程。 +请注意,我们不能在原子主机上使用 dnf 命令。原子主机并没有设计为通用操作系统,而是更适合容器和其他用途。但在原子主机上设置应用程序和服务仍然非常容易。这篇文章向您展示了如何自动化和简化这个过程。 ### 设置组件 -开始之前,请确保你的系统上安装了Ansible。 +开始之前,请确保你的系统上安装了 Ansible。 ``` sudo dnf -y install ansible ``` +首先,我们需要在原子主机上运行 cockpit 容器。在你的机器上从 https://github.com/trishnaguha/fedora-cloud-ansible 下载它的源代码。 + ``` $ git clone https://github.com/trishnaguha/fedora-cloud-ansible.git ``` +现在切换到 `cockpit` 的目录,并如下编辑 `inventory` 文件: ``` $ cd fedora-cloud-ansible $ cd cockpit $ vim inventory ``` -1. 使用你的Atomic 主机IP替换掉 IP_ADDRESS_OF_HOST。 -2. 用您的SSH私钥文件的路径替换行ansible_ssh_private_key_file ='PRIVATE_KEY_FILE'中的PRIVATE_KEY_FILE。 +完成如下修改: -现在保存并退出 inventory 文件。 +1. 使用你的原子主机的 IP 替换掉 `IP_ADDRESS_OF_HOST`。 +2. 用您的 SSH 私钥文件的路径替换 `ansible_ssh_private_key_file ='PRIVATE_KEY_FILE'` 行中的`PRIVATE_KEY_FILE`。 + +然后保存并退出 `inventory` 文件编辑。 接下来,编辑 ansible 配置文件: @@ -37,41 +43,43 @@ $ vim inventory $ vim ansible.cfg ``` -### 把他们放在一起! +替换 `remote_user=User` 中 `User` 为你的原子主机上的远程用户名。然后保存并退出文件编辑。 -现在是运行PlayBook的时候了。此命令开始运行Atomic主机上的Cockpit容器: +### 结合起来 + +现在是运行 Ansible 的 PlayBook 的时候了。此命令开始运行原子主机上的 Cockpit 容器: ``` $ ansible-playbook cockpit.yml ``` -[![Cockpit login screen](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-02-27.jpg?resize=676%2C321&ssl=1)](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-02-27.jpg?ssl=1) +Cockpit 现在运行在原子主机上了。使用浏览器去访问你的实例的公网 IP 的 9090 端口——这是 Cockpit 的默认端口。举个例子,如果该实例的 IP 地址是 192.168.1.4,就去访问 192.168.1.4:9090,你将会看到如下的 Web 界面: + +![Cockpit login screen](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-02-27.jpg?ssl=1) ### 管理你的容器 -使用Atomic主机的凭据或以root用户身份登录。然后访问Cockpit管理器上的Containers部分,查看Atomic主机上运行的容器。在下面的示例中,您会看到我还设置了其他类似 [httpd](https://github.com/trishnaguha/fedora-cloud-ansible/tree/master/httpd) 和 [redis](https://github.com/trishnaguha/fedora-cloud-ansible/tree/master/redis): +使用原子主机的登录信息或以 root 用户身份登录。然后访问 Cockpit 管理器上的 Containers 部分来查看原子主机上运行的容器。在下面的示例中,您会看到我还设置了其他容器,如 [httpd](https://github.com/trishnaguha/fedora-cloud-ansible/tree/master/httpd) 和 [redis](https://github.com/trishnaguha/fedora-cloud-ansible/tree/master/redis): -[![Cockpit panel for managing containers](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-13-05.jpg?resize=676%2C284&ssl=1)](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-13-05.jpg?ssl=1) +![Cockpit panel for managing containers](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-13-05.jpg?ssl=1) -注意,该界面允许您直接在Cockpit管理器中使用Run和Stop按钮启动和停止容器。您还可以使用Cockpit管理器管理您的Atomic主机。转到工具 - >终端。在这里里你可以使用Atomic主机的终端: +注意,该界面允许您直接在 Cockpit 管理器中使用 Run 和 Stop 按钮启动和停止容器。您还可以使用 Cockpit 管理器管理您的原子主机。转到 Tools -> Terminals,在这里里你可以使用原子主机的终端: -[![Cockpit terminal panel](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-10-19.jpg?resize=676%2C279&ssl=1)](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-10-19.jpg?ssl=1) +![Cockpit terminal panel](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-10-19.jpg?ssl=1) -如果您打算在Atomic主机上部署容器化的应用程序,则可以简单地为其编写PlayBook。然后,您可以使用ansible-playbook命令进行部署,并使用Cockpit管理容器。 +如果您打算在原子主机上部署容器化的应用程序,则可以简单地为其编写一个 PlayBook。然后,您可以使用 `ansible-playbook` 命令进行部署,并使用 Cockpit 来管理容器。 -[![Running ansible-playbook to deploy multiple containers](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/FotoFlexer_Photo51.jpg?resize=650%2C663&ssl=1)](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/FotoFlexer_Photo51.jpg?ssl=1) +![Running ansible-playbook to deploy multiple containers](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/FotoFlexer_Photo51.jpg?ssl=1) -你可以随意的Fork或添加容器的PlayBook在这个仓库 [https://github.com/trishnaguha/fedora-cloud-ansible](https://github.com/trishnaguha/fedora-cloud-ansible). +欢迎你对这个[仓库](https://github.com/trishnaguha/fedora-cloud-ansible)进行分支或添加容器的 PlayBook。 ------ via: https://fedoramagazine.org/deploy-containers-atomic-host-ansible-cockpit/ 作者:[trishnag][a] - 译者:[Bestony](https://github.com/Bestony) - -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出