chef / cookstyle

A linting tool that helps you to write better Chef Infra cookbooks and InSpec profiles by detecting and automatically correcting style, syntax, and logic mistakes in your code.
Apache License 2.0
109 stars 54 forks source link

remote_file: using a not_if to check if the file doesnt' already exist #906

Closed tas50 closed 2 years ago

tas50 commented 3 years ago
  remote_file "Download #{key} file" do
    path node['alfresco']['data'] + '/keystore/' + key
    owner node['alfresco']['apps_user']
    group node['alfresco']['apps_group']
    mode '0644'
    source node['alfresco']['keystore_link'] + '/' + key
    not_if { ::File.exist?(node['alfresco']['data'] + '/keystore/' + key) }
  end

  remote_file node.normal['tomcat']['home'] + '/lib/postgresql-jdbc.jar' do
    owner node['alfresco']['apps_user']
    group node['alfresco']['apps_group']
    mode '0644'
    source node['alfresco']['postgresql_jdbc_link']
    not_if { ::File.exist?(node.normal['tomcat']['home'] + '/lib/postgresql-jdbc.jar') }
  end

These could be done with :create_if_missing action instead.

tas50 commented 2 years ago

Will ship in the next release