Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Deploy airprint-generate script
Browse files Browse the repository at this point in the history
and avoid usage of git cookbook dependency
  • Loading branch information
artem-sidorenko committed Jun 30, 2017
1 parent e38ad50 commit 0e75b6d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
7 changes: 0 additions & 7 deletions README.md
Expand Up @@ -23,13 +23,6 @@ Attributes
| ['cups']['server_aliases'] | array | [] | List of allowed domains for remote administration |
| ['cups']['require_authentication'] | boolean | false | Specifies whether authentication is required to access the CUPS website and printers. |

### cups::airprint

| Key | Type | Default | Description |
| --------------------------------------------- | ------- | ----------- | ------------------------------------------ |
| ['cups']['airprint_generate']['git_url'] | string | https://github.com/tjfontaine/airprint-generate.git | URL to the airprint file generator repo. |
| ['cups']['airprint_generate']['git_revision'] | string | master | Git repo tag/version to pull. |

### cups::default_printer

| Key | Type | Default | Description |
Expand Down
3 changes: 0 additions & 3 deletions attributes/default.rb
Expand Up @@ -28,6 +28,3 @@

# specify whether authentication is required to access the website and printers
default['cups']['require_authentication'] = false

default['cups']['airprint']['airprint_generate']['git_url'] = 'https://github.com/tjfontaine/airprint-generate.git'
default['cups']['airprint']['airprint_generate']['git_revision'] = 'master'
2 changes: 0 additions & 2 deletions metadata.rb
Expand Up @@ -10,8 +10,6 @@

chef_version '>= 12.5' if respond_to?(:chef_version)

depends 'git', '~> 6.0'

%w[ubuntu debian redhat centos amazon scientific smartos].each do |os|
supports os
end
21 changes: 12 additions & 9 deletions recipes/airprint.rb
Expand Up @@ -28,8 +28,6 @@
)
end

include_recipe 'git::default'

if node['platform_family'] == 'rhel'
package 'avahi'
package 'python-lxml'
Expand Down Expand Up @@ -64,17 +62,22 @@

# Generate Avahi AirPrint service definition XML files
#
# 1. Checkout airprint-generate.py git repo
# 1. Deploy airprint-generate.py script
# 2. Run airprint-generate.py script
# 3. Copy `.service` files to /etc/avahi/services/
git "#{Chef::Config[:file_cache_path]}/airprint-generate" do
repository node['cups']['airprint']['airprint_generate']['git_url']
revision node['cups']['airprint']['airprint_generate']['git_revision']
action :sync

cookbook_cache = File.join(Chef::Config[:file_cache_path], cookbook_name)
airprint_generate_script = File.join(cookbook_cache, 'airprint-generate.py')

directory cookbook_cache

cookbook_file airprint_generate_script do
source 'airprint-generate.py'
mode '0644'
end

execute 'generate_airprint_service_definitions' do
cwd "#{Chef::Config[:file_cache_path]}/airprint-generate"
cwd cookbook_cache
if node['platform_family'] == 'debian'
# sleep is necessary here to ensure cups reload is finished before
# execution during initial run
Expand All @@ -90,7 +93,7 @@
end

bash 'copy_airprint_service_definitions' do
cwd "#{Chef::Config[:file_cache_path]}/airprint-generate"
cwd cookbook_cache
code 'cp *.service /etc/avahi/services/'
umask '0022'
user 'root'
Expand Down

0 comments on commit 0e75b6d

Please sign in to comment.