首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

对于Chef (12.5)自定义资源,如何从另一个操作调用一个操作并保留顺序?

对于Chef (12.5)自定义资源,如何从另一个操作调用一个操作并保留顺序?

在Chef (12.5)中,可以通过使用notifiessubscribes来从一个操作调用另一个操作并保留顺序。

  1. notifies:在一个操作中,可以使用notifies通知另一个操作执行。当指定的条件满足时,通知将被发送给另一个操作。示例代码如下:
代码语言:txt
复制
my_custom_resource 'resource_name' do
  action :create
  notifies :run, 'another_custom_resource[resource_name]', :immediately
end

another_custom_resource 'resource_name' do
  action :nothing
  # 执行的操作
end

在上述示例中,当my_custom_resourcecreate操作完成后,将立即通知another_custom_resourcerun操作执行。

  1. subscribes:在一个操作中,可以使用subscribes订阅另一个操作的执行。当指定的条件满足时,订阅将触发当前操作执行。示例代码如下:
代码语言:txt
复制
another_custom_resource 'resource_name' do
  action :create
  # 执行的操作
  subscribes :run, 'my_custom_resource[resource_name]', :immediately
end

my_custom_resource 'resource_name' do
  action :nothing
end

在上述示例中,当another_custom_resourcecreate操作执行时,将立即订阅my_custom_resourcerun操作,触发当前操作执行。

通过使用notifiessubscribes,可以在Chef (12.5)中实现从一个操作调用另一个操作并保留顺序。这种方式可以确保在特定条件下,操作按照指定的顺序执行。

腾讯云相关产品和产品介绍链接地址:

  • 腾讯云服务器(CVM):https://cloud.tencent.com/product/cvm
  • 腾讯云云原生容器服务(TKE):https://cloud.tencent.com/product/tke
  • 腾讯云数据库(TencentDB):https://cloud.tencent.com/product/cdb
  • 腾讯云对象存储(COS):https://cloud.tencent.com/product/cos
  • 腾讯云区块链服务(Tencent Blockchain):https://cloud.tencent.com/product/tbc
  • 腾讯云人工智能(AI):https://cloud.tencent.com/product/ai
  • 腾讯云物联网(IoT):https://cloud.tencent.com/product/iot
  • 腾讯云移动开发(MSS):https://cloud.tencent.com/product/mss
页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

领券