使用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管理的客户端使用您的本地仓库,您还需要进行下面的操作:
- 软件仓库创建一个存储库配置文件,如:
landscape-api create-repository-profile –description “This profile is for Landscape On-Premises servers.” example-profile - 计算机与存储库配置文件相关联,如:
landscape-api associate-repository-profile –tags example-tag example-profile - 将Pockets添加到存储库配置文件,如:
landscape-api add-pockets-to-repository-profile example-profile release,updates,security bionic ubuntu - 确认客户端 /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 - 如果需要恢复:
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 官方构建版 OpenJDK – 正式发布
长久以来,Java 在大型企业级软件开发领域占据领军地位,90% 的《财富》500 强企业将其用于后端开发,尤其在金融、医疗及政府等关键行业。 相较于大多数开发者,Java 开发者更需要承担这样的任务:在实现新功能与满足遗留应用的安全性、稳定性和性能等关键要求之间取得平衡。管理不同的 Java 版本、安全更新及部署构件,面临极大的复杂度。 基于上述原因,我们决定加强对工具链的投入,提供一套更全面的解决方案,让企业用户和社区成员都能从中受益。Canonical 的 OpenJDK 支持方案围绕以下核心原则构建: 下面我们将针对上述各要素逐步展开深入探讨。 安全增强保障:提供长效安全保障与稳定运行支持 Ubuntu Pro 订阅服务为所有 OpenJDK LTS 构建版提供 […]
《网络弹性法案》CRA 合规全指南:禁行与应行
Canonical 博客多次撰文探讨欧盟 CRA,而现在正是讨论这项新法规的影响以及它对物联网(IoT)和设备制造商在如何设计和构建具有数字元素的产品(PDE)的实际层面上的意义的最佳时机。 本文将深入剖析 IoT 制造商及 PDE 开发者亟待整改的常见实践,并给出合规改造方案,助您的工作成果和 PDE 在符合 CRA 的前提下持续立足欧盟市场。 《网络弹性法案》(CRA)下的禁行之举及应行之事 根据 CRA 规定,企业可执行与禁止的行为范畴根本上取决于其自身及所涉 PDE 在该新颁布法案中的分级或归类。若您尚未掌握 CRA 的法定措辞、分级机制及合规要求,可通过研读笔者往期专题文章系统掌握细则解读: 然而,CRA 在特定类别和分类要求之外,引入了极其广泛的变革,这些变革 […]
NVIDIA Jetson Thor 将支持运行 Ubuntu
Ubuntu 系统即将对 NVIDIA 的 Jetson Thor 系列产品提供官方支持,将与 NVIDIA 继续展开战略合作,共同推动边缘 AI 创新。Canonical 的官方支持将提供优化的 Ubuntu 镜像以及企业级的稳定性与安全性保障。该长期支持及安全更新承诺,可以确保 Ubuntu 系统与 NVIDIA Jetson 系统级模块的组合具备企业级的稳定性与可靠性。 NVIDIA Jetson Thor:一款适用于物理 AI 和机器人技术的强大边缘平台 NVIDIA 近期宣布推出 Jetson AGX Thor 开发人员套件及 Jetson Thor™ 系列模块。NVIDIA Jetson AGX Thor 开发人员套件是一款面向人形机器人技术与物理 AI 应用 […]