Puppet file 指令删除目标目录中的不在源目录中的文件

file {‘/home/op/open-falcon-agent/plugin’:
path => ‘/home/op/open-falcon-agent/plugin/’,
source => ‘puppet:///modules/sre-scripts/’,
recurse => true,
ignore => ‘.git’,
group => root,
owner => root,
mode => 755,
purge => true,
force => true,
require => Package[‘open-faclon-agent’]
}

这段配置,把 puppet:///modules/sre-scripts/ 中的目录和文件同步到 /home/op/open-falcon-agent/plugin,如果想把 /home/op/open-falcon-agent/plugin 中不在 puppet:///modules/sre-scripts/ 中的文件和目录删除掉,可以使用:

purge => true,
force => true,

purge => 默认会删除文件,不会删除目录,再配合使用 force => true,可以把不存在的目录删掉。

2F7828D7-1698-4746-A268-0D7C3965B027

 

参考:

https://docs.puppet.com/puppet/latest/reference/type.html

 

aws boto 停止 和 删除实例

停止实例

import boto.ec2

region = ""
aws_access_key_id = ""
aws_secret_access_key = ""

conn = boto.ec2.connect_to_region(region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)

instance_list = []

conn.stop_instances(instance_ids=instance_list)

删除实例

import boto.ec2

region = ""
aws_access_key_id = ""
aws_secret_access_key = ""

conn = boto.ec2.connect_to_region(region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)

instance_list = []

for instance in instance_list :
 conn.modify_instance_attribute(instance, "disableApiTermination", False)

conn.terminate_instances(instance_ids=instance_list)