谢谢您的订阅!
当新的内容发布后您将开始接收邮件。您也可以点击邮件内的链接随时取消订阅。关闭Close

使用Ubuntu系统管理工具Landscape来构建离线APT仓库:第三篇

by liam zheng on 26 January 2022

继续第二篇博客文章,现在我们将注册Landscape客户端到服务端并管理软件仓库。

使用 https注册客户端

客户端可以通过https的方式进行注册从而使用本地软件仓库。大概的操作步骤如下:

  • sudo apt-get update
  • sudo apt-get install landscape-client
  • 从Landscape服务器传送/etc/ssl/certs/landscape_server_ca.crt landscape到客户端
  • 客户端能解析到Landscape服务器的FQDN
  • sudo landscape-config –account-name standalone –url https://<server>/message-system –ping-url http://<server>/ping
  • 从Landscape server 仪表板接受注册的客端 

演示代码如下:

ubuntu@vm-ceph1:~$ sudo mv landscape_server_ca.crt /etc/ssl/certs/
ubuntu@vm-ceph1:~$ ping -c1 vm-landscape-server.maas
PING vm-landscape-server.maas (192.168.122.91) 56(84) bytes of data.
64 bytes from vm-landscape-server.maas (192.168.122.91): icmp_seq=1 ttl=64 time=0.430 ms
ubuntu@vm-ceph1:~$
ubuntu@vm-ceph1:~$ sudo landscape-config --account-name standalone --url https://vm-landscape-server.maas/message-system --ping-url http://vm-landscape-server.maas/ping
enabled

This script will interactively set up the Landscape client. It will
ask you a few questions about this computer and your Landscape
account, and will submit that information to the Landscape server.
After this computer is registered it will need to be approved by an
account administrator on the pending computers page.

Please see https://landscape.canonical.com for more information.


The computer title you provide will be used to represent this
computer in the Landscape user interface. It's important to use
a title that will allow the system to be easily recognized when
it appears on the pending computers page.

This computer's title [vm-ceph1]: 

A registration key may be associated with your Landscape
account to prevent unauthorized registration attempts.  This
is not your personal login password.  It is optional, and unless
explicitly set on the server, it may be skipped here.

If you don't remember the registration key you can find it
at https://landscape.canonical.com/account/standalone

Account registration key: 

The Landscape client communicates with the server over HTTP and
HTTPS.  If your network requires you to use a proxy to access HTTP
and/or HTTPS web sites, please provide the address of these
proxies now.  If you don't use a proxy, leave these fields empty.

HTTP proxy URL: 
HTTPS proxy URL: 

Landscape has a feature which enables administrators to run
arbitrary scripts on machines under their control. By default this
feature is disabled in the client, disallowing any arbitrary script
execution. If enabled, the set of users that scripts may run as is
also configurable.

Enable script execution? [Y/n]: y

By default, scripts are restricted to the 'landscape' and
'nobody' users. Please enter a comma-delimited list of users
that scripts will be restricted to. To allow scripts to be run
by any user, enter "ALL".

Script users [ALL]: 

You may provide an access group for this computer e.g. webservers.

Access group [ceph]: 

You may provide tags for this computer e.g. server,precise.

Tags [vm-ceph1]: 
Please wait...

Request a new registration for this computer now? [Y/n]: Y
System successfully registered.
ubuntu@vm-ceph1:~$ 

完成上述操作后,从仪表板接受客户端:

接受后,您可以看到这台计算机的标签是“vm-ceph1”,此标签将用于下一步的操作。

管理软件仓库

要让由Landscape管理的客户端使用您的本地仓库,您还需要进行下面的操作:

  1. 软件仓库创建一个存储库配置文件,如:
    landscape-api create-repository-profile –description “This profile is for Landscape On-Premises servers.” example-profile
  2. 计算机与存储库配置文件相关联,如:
    landscape-api associate-repository-profile –tags example-tag example-profile
  3. 将Pockets添加到存储库配置文件,如:
    landscape-api add-pockets-to-repository-profile example-profile release,updates,security bionic ubuntu
  4. 确认客户端 /etc/apt/source.list 变成:
    deb http://your-server.com/repository/standalone/ubuntu focal-security main restricted universe multiverse
    deb http://your-server.com/repository/standalone/ubuntu focal main restricted universe multiverse
    deb http://your-server.com/repository/standalone/ubuntu focal-updates main restricted universe multiverse
  5. 如果需要恢复:
    landscape-api disassociate-repository- profile –tags example-tag example-profile

示例命令和输出:

ubuntu@vm-landscape-server:~$ landscape-api create-repository-profile --description "This profile is for Landscape On-Premises servers." example-profile
{u'access_group': u'global',
 u'all_computers': False,
 u'apt_sources': [],
 u'description': u'This profile is for Landscape On-Premises servers.',
 u'id': 1,
 u'name': u'example-profile',
 u'pending_count': 0,
 u'pockets': [],
 u'tags': [],
 u'title': u'example-profile'}
ubuntu@vm-landscape-server:~$

ubuntu@vm-landscape-server:~$ landscape-api associate-repository-profile --tags vm-ceph1 example-profile
{u'access_group': u'global',
 u'all_computers': False,
 u'apt_sources': [],
 u'description': u'This profile is for Landscape On-Premises servers.',
 u'id': 1,
 u'name': u'example-profile',
 u'pending_count': 1,
 u'pockets': [],
 u'tags': [u'vm-ceph1'],
 u'title': u'example-profile'}
ubuntu@vm-landscape-server:~$

ubuntu@vm-landscape-server:~$ landscape-api add-pockets-to-repository-profile example-profile updates focal ubuntu
{u'access_group': u'global',
 u'all_computers': False,
 u'apt_sources': [],
 u'description': u'This profile is for Landscape On-Premises servers.',
 u'id': 1,
 u'name': u'example-profile',
 u'pending_count': 1,
 u'pockets': [{u'apt_source_line': u'deb http://vm-landscape-server.maas/repository/standalone/ubuntu focal-updates restricted',
               u'architectures': [u'amd64'],
               u'components': [u'restricted'],
               u'creation_time': u'2022-01-04T08:50:46Z',
               u'gpg_key': {u'fingerprint': u'be50:6aea:aaaa:977f:0302:b161:c308:d9a6:a02f:e060',
                            u'has_secret': True,
                            u'id': 1,
                            u'key_id': u'C308D9A6A02FE060',
                            u'name': u'mirror-key'},
               u'include_udeb': False,
               u'mirror_suite': u'focal-updates',
               u'mirror_uri': u'http://hk.archive.ubuntu.com/ubuntu/',
               u'mode': u'mirror',
               u'name': u'updates'}],
 u'tags': [u'vm-ceph1'],
 u'title': u'example-profile'}
ubuntu@vm-landscape-server:~$

到此就完成了利用Landscape创建APT本地离线软件仓库的教程。Landscape系统管理工具可免费在10台机器上使用,如您有超过10台的机器需要使用Landscape来管理,那么建议您通过Ubuntu Advantage订阅服务来获得单节点最多40000台机器的功能。

如您有相关问题,可联系我们以了解更多关于Landscape的支持服务内容。

附录: 有用的参考文档链接

可继续阅读:第一篇第二篇博客文章。

订阅博客文章

订阅您感兴趣的主题

在提交此表格的同时,我确认已阅读和同意的隐私声明隐私政策。

查看更多内容

Canonical 发布 Ubuntu 24.04 LTS Noble Numbat

Canonical 的第 10 个长期支持版本树立了在性能工程、企业安全和开发人员体验方面的新标准。 伦敦,2024 年 4 月 25 日 Canonical 今日正式发布 Ubuntu 24.04 LTS,代号“Noble Numbat”(尊贵的袋食蚁兽),用户可前往 https://ubuntu.com/download 下载并安装。 Ubuntu 24.04 LTS 建立在前三个中期版本的进步以及世界各地开源开发人员的贡献之上,只为确保一个安全、优化和具有前瞻性的平台。 Canonical 首席执行官 Mark Shuttleworth 称:“Ubuntu 24.04 LTS 在性能工程和机密计算方面迈出了大胆的一步,实现了一个企业级创新平台,支持期限至少为 12 […]

Canonical 从 Ubuntu 14.04 LTS 开始将安全支持期限延长至 12 年

Canonical 全面推出 Ubuntu Pro 附加组件 Legacy Support,并将 Ubuntu LTS 版本的安全支持延至 12 年。该附加组件将适用于 Ubuntu 14.04 LTS 及之后的版本。 长期支持的 Ubuntu 版本可享受针对主要 Ubuntu 资源库的五年标准安全维护。Ubuntu Pro 将针对主要资源库和总体资源库的这一安全维护承诺期限延至 10 年,为企业和最终用户等提供了一个巨大的安全开源软件库。订阅还可享受电话和工单等支持服务。Ubuntu Pro 付费客户可以购买新推出的 Legacy Support 附加组件,享受额外两年的安全维护和支持服务。 Canonical 支持工程全球副总裁 Maximilian Morgan 称 […]

新吉祥物加冕礼:Noble Numbat

无论是通过民众投票、天意还是湖中仙女赐予王者之剑,登上王位的往往是声名显赫或出身高贵的人。在我们 20 周年前夕,很高兴向大家展示 Ubuntu 24.04 LTS 的吉祥物—— Noble Numbat(尊贵的袋食蚁兽)。  低微出身  说到 “尊贵”,人们可能很难首先想到来自澳大利亚的神秘有袋类动物——袋食蚁兽。不过它们的外表非常具有欺骗性。这些不可思议的濒危物种实际上是口袋大小的食蚁兽,它们完全以蚂蚁为食,依靠身体三分之一长的舌头捕捉蚂蚁。它们的背部有着黑白相间的条纹,像极了王袍,因而被选为西澳大利亚州的象征动物。袋食蚁兽象征着出身低微也能享誉世界的人。 至高成就 同样,Ubuntu 也从构建更加人性化的 Linux 这样一个初出茅庐的梦想发展成为一个备受信赖的平台 […]