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

cf-sketch interactive mode does not work with multi-dimensional arrays #240

Open
nickanderson opened this issue Jan 28, 2013 · 20 comments
Open
Assignees
Milestone

Comments

@nickanderson
Copy link
Member

Try configuring Repository::apt::Maintain

cf-sketch> configure Repository::apt::Maintain

Entering interactive configuration for sketch Repository::apt::Maintain.
Please enter the requested parameters (enter STOP to abort):

Parameter 'repos' must be an array.
Please enter each key and value in turn, empty key to finish.
Please enter next key: handbrake
Please enter value for repos[handbrake]: distrib
Please enter next key: 
Sorry, but KVARRAY validation was requested on a non-array entry value 'distrib'.  We'll fail the validation.
Array validation failed. Resetting, please reenter all the values.
@ghost ghost assigned tzz Feb 15, 2013
@tzz
Copy link
Contributor

tzz commented Feb 15, 2013

We plan to approach this in two ways:

  • stop using deeply nested arrays so much
  • when we use them, support them better (so yes, this ticket is valid)

@nickanderson
Copy link
Member Author

But I WANT to use deeply nested arrays, it builds character ;)

@ghost ghost assigned zzamboni May 10, 2013
@tzz
Copy link
Contributor

tzz commented May 10, 2013

@zzamboni is working on it.

@zzamboni
Copy link
Contributor

Interactive configuration mode has now been reimplemented for the new cf-sketch. Please see and test #309.

It still doesn't work with deeply-nested arrays though, since the drive seems to be towards simplification of parameters. I think for complex data structures you are better off editing the JSON file directly anyway.

@shreyu82
Copy link

yes i got the same issue while configure Users::Local on interactive mode it is very had to set the value and it is not set throw the error.
"local" : [
{ "name" : "runenv", "type" : "environment" },
{ "name" : "metadata", "type" : "metadata" },
{ "name" : "users", "type" : "array" },
{ "name" : "options", "type" : "array", default: { groupname: "defaultgroup" } },
],
any other way to insert data on interactive mode .?

@tzz
Copy link
Contributor

tzz commented Dec 19, 2013

@shreyu82 @zzamboni I looked around for tools that implement this kind of editing and can't find any. Pointers and suggestions welcome so we know what kind of patterns already exist.

@zzamboni
Copy link
Contributor

I still think interactive parameter entry is not well suited for complex data structures, it's simply too error prone. The best would be to automatically put the user in an $EDITOR session with the JSON file preloaded, so they can edit the values. Upon exit, validate and if there are any errors, go back to the editor.

@nickanderson
Copy link
Member Author

I disagree from an ease of use standpoint. Answering questions or a menu
based CLI interface is more intuitive, I think we should strive for a rich
CLI interface. We could do the editor thing as a stopgap. Or have that
first and then a config option that allows you to choose an interactive
mode (when we have time to build it) or editor mode.
On Dec 20, 2013 3:44 PM, "Diego Zamboni" notifications@github.com wrote:

I still think interactive parameter entry is not well suited for complex
data structures, it's simply too error prone. The best would be to
automatically put the user in an $EDITOR session with the JSON file
preloaded, so they can edit the values. Upon exit, validate and if there
are any errors, go back to the editor.


Reply to this email directly or view it on GitHubhttps://github.com//issues/240#issuecomment-31050133
.

@shreyu82
Copy link

@zzamboni : but that array things works with Security::SSH modules how ? that is my questations.

see info of Security::SSH
ketch Security::SSH
Description: Configure and enable sshd
Authors: Diego Zamboni diego.zamboni@cfengine.com, Ted Zlatanov tzz@lifelogs.com
Version: 1.1
License: MIT
Tags: cfdc
Installed: Yes, under /var/cfengine/masterfiles/sketches
Activated: No
Parameters:
For bundle sshd
params: array

but but but it cant work for Security::security_limits & Users::Local

@zzamboni
Copy link
Contributor

@shreyu82 the parameter types are different. In Security::SSH is a plain array of key/value pairs, whereas in Users::Local it's a list of arrays, and in Security::security_limits it's a nested array.

@shreyu82
Copy link

@zzamboni but how to pass that nested array using interactive mode using cf-sketch cause i am using that mode only . so any video avaialable to pass or any method ? currently i impret them using .json file .

@shreyu82
Copy link

Users::Local it's a list of arrays, and in Security::security_limits it's a nested array. how to pass on non-interactive mode ? i passed using as mentioned below

cf-sketch> define params Users::Local

This sketch has multiple accessible bundles.
1. local(users, options)
2. runbased(checker, users, options)
Which one do you want to configure? (1-2, Enter to cancel) 1
Please enter a name for the new parameter set (default: Users::Local-local-000): oracle
Querying configuration for parameter set 'oracle' for bundle 'local'.
Please enter parameter users.
(enter STOP to cancel)
Next key (Enter to finish): oracle
users[oracle]: { 'Oracle user", 1001, 1002, /home/oracle, /bin/bash, 'test'}
Next key (Enter to finish):
Please enter parameter options.
(enter STOP to cancel)
Next key (Enter to finish)[groupname]: groupname
options[groupname][defaultgroup]: oracle
Next key (Enter to finish):
Defining parameter set 'oracle' with the entered data.

Parameter set oracle successfully defined.

I attached jpg file too

user_local

" users[oracle]: { 'Oracle user", 1001, 1002, /home/oracle, /bin/bash, 'test'} "
which is not work well .

@zzamboni
Copy link
Contributor

As I said before, interactive mode in cf-sketch does not support complex data types. You need to store the parameters in a JSON file and load it by passing it as a second argument to the "define params" command, for example:

define params Users::Local /path/to/params.json

Most sketches include sample JSON parameter files under their params/ directory (for example, design-center/sketches/system/users_local/params/demo.json)

--Diego

On Dec 24, 2013, at 3:54 AM, shreyu82 notifications@github.com wrote:

Users::Local it's a list of arrays, and in Security::security_limits it's a nested array. how to pass on non-interactive mode ? i passed using as mentioned below

cf-sketch> define params Users::Local

This sketch has multiple accessible bundles.

  1. local(users, options)
  2. runbased(checker, users, options)
    Which one do you want to configure? (1-2, Enter to cancel) 1
    Please enter a name for the new parameter set (default: Users::Local-local-000): oracle
    Querying configuration for parameter set 'oracle' for bundle 'local'.
    Please enter parameter users.
    (enter STOP to cancel)
    Next key (Enter to finish): oracle
    users[oracle]: { 'Oracle user", 1001, 1002, /home/oracle, /bin/bash, 'test'}
    Next key (Enter to finish):
    Please enter parameter options.
    (enter STOP to cancel)
    Next key (Enter to finish)[groupname]: groupname
    options[groupname][defaultgroup]: oracle
    Next key (Enter to finish):
    Defining parameter set 'oracle' with the entered data.

Parameter set oracle successfully defined.

I attached jpg file too

" users[oracle]: { 'Oracle user", 1001, 1002, /home/oracle, /bin/bash, 'test'} "
which is not work well .


Reply to this email directly or view it on GitHub.

@shreyu82
Copy link

shreyu82 commented Jan 1, 2014

Okay thanks zzamboni. i also used it like below from non-interactive

/usr/local/bin/cf-sketch --expert --installsource=/var/cfengine/design-center/sketches/system/users_local/params/demo.json --cfpath=/var/cfengine/bin --test --activated --force --standalone --install CFEngine::stdlib --deactivate-all --generate -v --force --standalonerunfile /var/cfengine/inputs/standalone-cf-sketch-runfile.cf --install Utilities::abortclasses --activate Utilities::abortclasses=/var/cfengine/design-center/sketches/utilities/abortclasses/params/test_alert_only.json

Okay got you thanks zzamboni

@zzamboni
Copy link
Contributor

zzamboni commented Jan 7, 2014

Glad you got it working!

--Diego

On Jan 1, 2014, at 2:12 AM, shreyu82 notifications@github.com wrote:

Okay thanks zzamboni. i also used it like below from non-interactive

/usr/local/bin/cf-sketch --expert --installsource=/var/cfengine/design-center/sketches/system/users_local/params/demo.json --cfpath=/var/cfengine/bin --test --activated --force --standalone --install CFEngine::stdlib --deactivate-all --generate -v --force --standalonerunfile /var/cfengine/inputs/standalone-cf-sketch-runfile.cf --install Utilities::abortclasses --activate Utilities::abortclasses=/var/cfengine/design-center/sketches/utilities/abortclasses/params/test_alert_only.json

Okay got you thanks zzamboni


Reply to this email directly or view it on GitHub.

@shreyu82
Copy link

shreyu82 commented Jan 7, 2014

Yeah zzamboni but I am still try to find solution for how to pass variable value using nested arrays with interactive mode. ;-)

@shreyu82
Copy link

shreyu82 commented Jan 7, 2014

@zzamboni any idea why default lib : "manage_variable_values_ini" function not work well in CF3 .it return error while change value in php.ini
value should be something like that
[ SQL]
sql.safe_mode = off ( i want "on" here but it delete whole line when i used "manage_variable_values_ini" function )

@shreyu82
Copy link

@zzamboni any idea how do i call folder in sketch.json under manifest block
{
"main.cf": { desc: "main file" },
"files/etc/init.d/firewall": { desc: "firewall init script" },
"files/etc/firewall/firewall": { desc: "firewall init script" },
"target": { "files/etc/firewall/conf.d/": "/etc/firewall/conf.d/" }
},
but it gave error

@shreyu82
Copy link

any idea how it ?

@tzz
Copy link
Contributor

tzz commented Jan 15, 2014

Hi @shreyu82

The manifest currently does not support directories as an install target. For what you describe, you really want to do the copying to the final destination in the sketch itself.

tzz pushed a commit to tzz/design-center that referenced this issue Jun 1, 2014
Removed "machines" from Host. Minor markdown cleanup.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants