Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 24AC01922F for ; Sat, 26 Mar 2016 09:28:18 +0000 (UTC) Received: (qmail 75949 invoked by uid 500); 26 Mar 2016 09:28:18 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 75913 invoked by uid 500); 26 Mar 2016 09:28:18 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 75901 invoked by uid 99); 26 Mar 2016 09:28:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Mar 2016 09:28:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 25DFF1A0CE5 for ; Sat, 26 Mar 2016 09:28:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=cloudsoftcorp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id eIdokPbu-A11 for ; Sat, 26 Mar 2016 09:28:14 +0000 (UTC) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id A703D5F3F0 for ; Sat, 26 Mar 2016 09:28:14 +0000 (UTC) Received: by mail-wm0-f53.google.com with SMTP id u125so37158354wmg.1 for ; Sat, 26 Mar 2016 02:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudsoftcorp.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=YmQ+Hi8/5wjHSauaqusbLoTVvL2kjKdeBUNXxBktq5A=; b=Rtj23a2PQ+GBEto6erCMnySRP+B5frnMWw6iFsedLU4MgvEhJ5f3Elpf+X/wNN2cTi NcD/oNWb0E+tKG1mDiRJff9lcKS0SWXGNmNbfARSq8apfYQqsi1M8/VIszh5Rl4KGl5j dYgn8bO6P4aufpaLoCZ+i9H5QkhMbippN2wUg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=YmQ+Hi8/5wjHSauaqusbLoTVvL2kjKdeBUNXxBktq5A=; b=Qj+7F9+7ecHnS+qcIlFEjWJk1wPM7/9VnYQE9XdEafiutkTrcxZNedpk90LGln2wua EGcshtKQOpndE8vXZwM9K6zUYPWnhmLJOqtRnXGXVDIAKKSM0+LARYjc+8NeJTdBjP29 GF6bjtyDwoqvlmuzcAg1Ek5AT8kUVKqt8EvHJ3YOxkDqQhVTruQ/d9DuQQ2AG7M67DHx biEY/9yiclr84lnRVQMdPhxXriGWzIptH782CxCb9q11Z0S44xzuY0Hy/rV/7owtMTCj 4+SEYFw88UqN6fvZjXIyAjQ0hrNGG0g8UG1HqbQQnBiX14I0wV8+u4HPMw5grzdI7S/L QzFA== X-Gm-Message-State: AD7BkJLavLt+CvORUzG4a92AKN8tlDd9JU4GJeHsqL2coKd7SNlYXOazTAhZ9fj0DAOZrCQtwx+UyJpS5sNSUP9jPQwVl2zIlt7cWRb4Kr+k9Z6ktuEivlwnve9Ez6IoPURAdX95xufjL5r61JM6Dw== MIME-Version: 1.0 X-Received: by 10.28.186.196 with SMTP id k187mr960616wmf.17.1458984488064; Sat, 26 Mar 2016 02:28:08 -0700 (PDT) Received: by 10.28.24.199 with HTTP; Sat, 26 Mar 2016 02:28:07 -0700 (PDT) Received: by 10.28.24.199 with HTTP; Sat, 26 Mar 2016 02:28:07 -0700 (PDT) In-Reply-To: References: Date: Sat, 26 Mar 2016 09:28:07 +0000 Message-ID: Subject: Re: parameterising config files From: Alex Heneveld To: dev@brooklyn.apache.org Content-Type: multipart/alternative; boundary=001a1148f7dc24ee88052ef04c60 X-Legal-Virus-Advice: Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by Cloudsoft Corporation Limited in this regard and the recipient should carry out such virus and other checks as it considers appropriate. X-Legal-Confidentiality: This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. Cloudsoft Corporation Limited does not accept responsibility for changes made to this message after it was sent. X-Legal-Company-Info: Cloudsoft Corporation Limited. Registered in Scotland. Number: SC349230. Registered Office: 13 Dryden Place, Edinburgh, EH9 1RP. --001a1148f7dc24ee88052ef04c60 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable John Good write up. This needs to be in brooklyn-docs! Best Alex On 25 Mar 2016 21:08, "John McCabe" wrote: > Hi David, > I've been using freemarker templates for this, and it works quite well, f= or > example: > > brooklyn.config: > templates.install: > "https://some.server.com/nginx.conf.template": > templates/nginx.conf > > Then using them in install.command, customize.command etc as follows: > > cp ${INSTALL_DIR}/templates/nginx.conf /etc/nginx/ > > The templates themselves are standard Freemarker [1], for example to get = at > a config property. > > ${config['management.https.port']?c} > > you can even do stuff like iterate over hashes: > > <#list config['jms.connectionfactories'] as factory> > factory.name}" connectors=3D"${factory.connector!"in-vm"}"/> > > > I can share an example with you if you like. (there are some existing > examples in the Brooklyn repos [2] [3] and others). > > I'm sure this isn't the only way to achieve the desired result, it proved > compelling for me vs sed due to the easy iteration and manipulation. > > /John > > [1] - http://freemarker.org/docs/index.html > [2] - > > https://github.com/apache/brooklyn-library/blob/master/software/nosql/src= /main/resources/org/apache/brooklyn/entity/nosql/mongodb/mongodb_win.yaml > [3] - > > https://github.com/apache/brooklyn-library/blob/master/software/database/= src/main/resources/org/apache/brooklyn/entity/database/mssql/mssql.yaml > > On Fri, 25 Mar 2016 at 17:29 David Bush > wrote: > > > Hi, > > > > As part of a blueprint I need to import some config files and inject > > values for parameters such as ip addresses gained from sensors or > > environment variables. > > > > I am currently using sed to replace parameters in the files which is > great > > for one or two but I need to increase the replacements to support > > additional functions. > > > > I am looking to use templates.install to copy the files. > > > > Can anyone advise best practice way to do this? I looked for examples i= n > > the repos but searching for templates.install did not reveal much (to > me). > > I can see sed being used elsewhere but nothing for multiple replacement= s. > > Guessing there must be a straight forward ${param}: param type method f= or > > doing this? > > > > Many thanks, > > David. > > > > -- > > David Bush =E2=80=A2 Systems Integrator =E2=80=A2 Cloudsoft Corporation= =E2=80=A2 > > http://www.cloudsoftcorp.com > > T: 07834 127195 =E2=80=A2 SKYPE: david.c.bush > > > > > --001a1148f7dc24ee88052ef04c60--