zend-patterns / ZendServerSDK

Pure ZF2 CLI for zpk creation and webapi client.
BSD 3-Clause "New" or "Revised" License
22 stars 17 forks source link

--template parameter example for zs-client.phar vhostAdd, vhostEdit, vhostValidateTemplate #87

Closed Schnaaf closed 8 years ago

Schnaaf commented 8 years ago

We are in the process of setting up continuous integration on Jenkins. We are having troubles setting up the required vhosts for Zend Server through zs-client.phar.

The problem I have is that I have no clue on how to specify the value for the template parameter in the commands vhostAdd, vhostEdit, vhostValidateTemplate

php /usr/local/bin/zs-client.phar vhostAdd --target=servertarget --name=vhostname --port=port --template=<???>

Can you provide an example for the --template parameter usage?

slaff commented 8 years ago

The --template option accepts as a value local-file-name or the actual template content. If you run the command with --help it will show you more information:

php /usr/local/bin/zs-client.phar vhostAdd --help

* vhostAdd --name= --port= [--template=] [--forceCreation=] [--target=] [--zsurl=] [--zskey=] [--zssecret=] [--zsversion=] [--http=] [--output-format=] 

Add a new virtual host. Receives name, port and template and returns a single virtual hostelement with the same information.
  --name             Name of virtual host.                                                                                                                                                                  
  --port             Port of virtual host.                                                                                                                                                                  
  --template         Template of the virtual host settings according to the web server configuration options. Or an absolute path to a local template vhost file.                                           
  --forceCreation    Force the creation of a virtual host, even if it fails syntax validation. Default: FALSE                                                                                               
  --output-format    Output format. Default is "xml", but you can use json or kv(for key-value) 
Schnaaf commented 8 years ago

Thanks for your answer and updates. In the meantime I got a more elaborate answer from Zend Support which answered my question in just the right amount of detail. Especially the .tpl extension requirement and pointing me to the examples located in /usr/local/zend/share/. Maybe it is worth it to add this to the documentation as well.

Answer from Zend Support:

While creating, editing or validating a Virtual Host using zs-client.phar, to specify a custom Virtual Host template using the --template option, you need to use any one of the following Virtual Host templates: Apache --> /usr/local/zend/share/vhost.tpl Apache with SSL --> /usr/local/zend/share/vhost-ssl.tpl NginX --> /usr/local/zend/share/vhost-nginx.tpl NginX with SSL --> /usr/local/zend/share/vhost-nginx-ssl.tpl You can create a copy of the template file (file extension must be ".tpl") and place it somewhere on your server, for example /root/vhost_templates. Then use this template file in the command. Here's a sample command to add a Virtual Host using zs-client.phar vhostAdd: # /usr/local/zend/bin/php zs-client.phar vhostAdd --name=samplevhost --port=80 --template=/root/vhost_templates/vhost_sample.tpl --forceCreation=true --zsurl=http://localhost:10081 --zskey=admin --zssecret=123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234 Note: The virtual host template file must be present locally on the server where you run the command.