Chef Solo get user input

后端 未结 2 842
后悔当初
后悔当初 2020-12-12 02:25

I don\'t know why I can\'t find anything on the interwebs about this.

I basically want to write a recipe that prompts a user for their github username/password, then

相关标签:
2条回答
  • 2020-12-12 02:31

    I'd say chef is not made for such user input.

    You might use ruby code that is executed during the compile phase of the chef run, but I'd suggest the following:

    What about reading it from an environment variable?

    0 讨论(0)
  • 2020-12-12 02:50

    It feels super dirty, but this actually works. Maybe some things can be tuned so that it feels a bit more clean:

    file "/tmp/ans" do
      puts "Enter something useful!"
      content ::STDIN.readline
    end
    

    You can apply such a recipe with chef-apply, note that using Vagrant will not work.

    Still, I would recommend do it differently. Another way would be to not call chef directly, but through a wrapper script. This could read the data from the user and write it into a json file, which is then given to chef via the -j PATH, --json-attributes PATH parameter (see chef-solo parameters).

    0 讨论(0)
提交回复
热议问题