Commit ffef2fa291bf04c6ac2b5b22ca4e7db199356670

Authored by Rodrigo Siqueira de Melo
1 parent 0a4a481b

Clean yum cache by default.

Cache can be kept by using the flag keep_yum_cache=1

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Sergio Oliveira <sergio@tracy.com.br>
Showing 2 changed files with 24 additions and 25 deletions   Show diff stats
@@ -52,6 +52,7 @@ end @@ -52,6 +52,7 @@ end
52 ips ||= YAML.load_file(ips_file) 52 ips ||= YAML.load_file(ips_file)
53 config ||= YAML.load_file(config_file) 53 config ||= YAML.load_file(config_file)
54 firewall ||= File.open(iptables_file).read 54 firewall ||= File.open(iptables_file).read
  55 +config['keep_yum_cache'] = ENV['keep_yum_cache'] ? true : false
55 $nodes.each do |node| 56 $nodes.each do |node|
56 node.data['environment'] = $SPB_ENV 57 node.data['environment'] = $SPB_ENV
57 node.data['config'] = config 58 node.data['config'] = config
cookbooks/basics/recipes/default.rb
  1 +
  2 +# our custom repositories
  3 +if node['platform'] == 'centos'
  4 + cookbook_file '/etc/yum.repos.d/softwarepublico.key' do
  5 + owner 'root'
  6 + mode 0644
  7 + end
  8 + template '/etc/yum.repos.d/softwarepublico.repo' do
  9 + owner 'root'
  10 + mode 0644
  11 + end
  12 +
  13 + unless node['config']['keep_yum_cache']
  14 + execute 'yum_clean_cache' do
  15 + command 'yum clean all'
  16 + end
  17 + # reload internal Chef yum cache
  18 + ruby_block "yum-cache-reload" do
  19 + block { Chef::Provider::Package::Yum::YumCache.instance.reload }
  20 + end
  21 + end
  22 +end
  23 +
1 # enable EPEL repository by default 24 # enable EPEL repository by default
2 package 'epel-release' 25 package 'epel-release'
3 26
@@ -65,31 +88,6 @@ end @@ -65,31 +88,6 @@ end
65 # FIXME on Debian it's postgresql-client 88 # FIXME on Debian it's postgresql-client
66 package 'postgresql' 89 package 'postgresql'
67 90
68 -# our custom repositories  
69 -if node['platform'] == 'centos'  
70 - cookbook_file '/etc/yum.repos.d/softwarepublico.key' do  
71 - owner 'root'  
72 - mode 0644  
73 - end  
74 - template '/etc/yum.repos.d/softwarepublico.repo' do  
75 - owner 'root'  
76 - mode 0644  
77 - notifies :run, "execute[yum_clean_cache]", :immediately  
78 - notifies :create, "ruby_block[yum-cache-reload]", :immediately  
79 - end  
80 - execute 'yum_clean_cache' do  
81 - command 'yum clean all'  
82 - action :nothing  
83 - end  
84 - # reload internal Chef yum cache  
85 - ruby_block "yum-cache-reload" do  
86 - block { Chef::Provider::Package::Yum::YumCache.instance.reload }  
87 - action :nothing  
88 - end  
89 -end  
90 -  
91 -  
92 -  
93 # reload node[:fqdn] to make sure it reflects the contents of /etc/hosts 91 # reload node[:fqdn] to make sure it reflects the contents of /etc/hosts
94 # without that the variable :fqdn would not be available on first run 92 # without that the variable :fqdn would not be available on first run
95 ruby_block 'fqdn:update' do 93 ruby_block 'fqdn:update' do