librarian-puppet icon indicating copy to clipboard operation
librarian-puppet copied to clipboard

Add --puppetfile option to the cli

Open xentek opened this issue 10 years ago • 12 comments

Bundler can do bundle install --gemfile=/path/to/Gemfile (and also responds to the BUNDLER_GEMFILE environment variable). It might be nice to have similar functionality in librarian-puppet so that one may install dependencies without having to change into the directory that contains the Puppetfile.

I run my Puppets master-less, and use cron to apply updates, so this would help me a bunch. If this seems reasonable and is a change that should be made on this repository, I'd be happy to work on a pull request (but figured I'd ask first). Until then, I'll just have my cron task cd into the directory.

xentek avatar Jun 11 '14 07:06 xentek

it sounds reasonable, I'd use that too ;)

carlossg avatar Jun 11 '14 08:06 carlossg

:thumbsup: me too

njam avatar Jun 11 '14 08:06 njam

Cool, I'll see if I can't put something together in the next few days.

xentek avatar Jun 11 '14 09:06 xentek

I need this in 1.0 as 1.1 is not supported in CentOS 6.X.

If it's done, I'll try to backport... any chance it will be merged in a 1.0.x release?

flozano avatar Jul 11 '14 10:07 flozano

yes, I'm planning to keep 1.0.x updated for a while if it doesn't get too cumbersome

carlossg avatar Jul 11 '14 11:07 carlossg

:+1:

flozano avatar Jul 11 '14 11:07 flozano

Is this finally happening anytime soon?

flozano avatar Jul 18 '14 10:07 flozano

I'm greping thru the code and the only references in non-test/non-documentation I can see are:

        unless File.exist?('Puppetfile')
          say "Could not find Puppetfile in #{Dir.pwd}", :red
          exit 1
        end

in the cli.rb... but that's just a check, I don't know from where it's taking the Puppetfile name...

flozano avatar Jul 18 '14 12:07 flozano

In librarian:

    def default_specfile_name
      @default_specfile_name ||= begin
        capped = adapter_name.capitalize
        "#{capped}file"
      end
    end

flozano avatar Jul 18 '14 12:07 flozano

I haven't gotten a chance to circle back around to this but should be able to  soon — Eric Marden

On Fri, Jul 18, 2014 at 7:49 AM, Francisco A. Lozano [email protected] wrote:

In librarian:

    def default_specfile_name
      @default_specfile_name ||= begin
        capped = adapter_name.capitalize
        "#{capped}file"
      end
    end

Reply to this email directly or view it on GitHub: https://github.com/rodjek/librarian-puppet/issues/226#issuecomment-49426719

xentek avatar Jul 18 '14 18:07 xentek

ok, thank you

flozano avatar Jul 25 '14 09:07 flozano

this issue has no bee touched in awhile, but thoughts on something like the following?

diff --git a/lib/librarian/puppet/cli.rb b/lib/librarian/puppet/cli.rb
index afb8e88..de864e4 100644
--- a/lib/librarian/puppet/cli.rb
+++ b/lib/librarian/puppet/cli.rb
@@ -47,6 +47,7 @@ module Librarian
       option "destructive", :type => :boolean, :default => false
       option "local", :type => :boolean, :default => false
       option "use-v1-api", :type => :boolean, :default => true
+      option "puppetfile", :type => :string
       def install

         ensure!
@@ -61,6 +62,9 @@ module Librarian
         if options.include?("path")
           environment.config_db.local["path"] = options["path"]
         end
+        if options.include?("puppetfile")
+          ENV["PUPPETFILE"] = options["puppetfile"]
+        end

         environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
         environment.config_db.local['mode'] = options['local'] ? 'local' : nil
diff --git a/lib/librarian/puppet/environment.rb b/lib/librarian/puppet/environment.rb
index d502415..73cdd30 100644
--- a/lib/librarian/puppet/environment.rb
+++ b/lib/librarian/puppet/environment.rb
@@ -11,6 +11,17 @@ module Librarian
         "puppet"
       end

+      def default_specfile_name
+        @default_specfile_name ||= begin
+          if ENV["PUPPETFILE"]
+            ENV["PUPPETFILE"]
+          else
+            capped = adapter_name.capitalize
+            "#{capped}file"
+          end
+        end
+      end
+
       def lockfile
         Lockfile.new(self, lockfile_path)
       end

jfarrell avatar Feb 23 '16 03:02 jfarrell