<div dir="ltr"><div class="gmail_default" style="font-size:small">Hello Gilbert,<br><br></div><div class="gmail_default" style="font-size:small">Thanks for the email. I have added the Juju list so others can chime too.<br></div><div class="gmail_default" style="font-size:small"><br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div class="gmail_default" style="font-size:small">Because Oracle-XE 11gR2 version requires accepting a license agreement to download from Oracle.com...</div></blockquote><div class="gmail_default" style="font-size:small">We are going to introduce a new concept in Juju 2.0 called "terms" where you can run an "accept" command for software with proprietary software. You would put "terms" key in your metadata.yaml. Check the release notes for some tips on this feature: <a href="https://jujucharms.com/docs/devel/temp-release-notes">https://jujucharms.com/docs/devel/temp-release-notes</a><br><br>Alternately you could make a configuration option where the user could accept the license on the Oracle page, and put the key in a configuration option, where the charm would not install if the key is empty or invalid.</div><div class="gmail_extra"><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div class="gmail_default" style="font-size:small;display:inline">So my install hook is taking shape kinda like this (and works): ...<br></div></blockquote><div><div class="gmail_default" style="font-size:small;display:inline">I would really encourage you to look at our new Developer documents ( <a href="https://jujucharms.com/docs/devel/developer-getting-started">https://jujucharms.com/docs/devel/developer-getting-started</a> ) that introduce charm layers and a reactive framework. From my experience it is much more "natural" to write charms this way where you can define states and react to them. As an example you could define: 'oracle.downloaded', 'oracle.configured', and 'oracle.available' and the code could react to different states.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">My question is, what is the best way to automate this last step for charm deployment?</blockquote></div></div><div class="gmail_default" style="font-size:small">Non interactive install scripts are the bane of my existence! I have a number of techniques to work around these, such as piping the "yes" command to a script, or redirecting strings into the interactive bits. The best approach is on a case to case basis, but you may have to re-write this script. I<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">...to just use the default values and to use some hardcoded default password. <br></blockquote><div>Hard coded passwords are never the right way to go and against Charm Store policy ( <a href="https://jujucharms.com/docs/devel/authors-charm-policy">https://jujucharms.com/docs/devel/authors-charm-policy</a> ). Either randomly generate a password that the user can retrieve or have that set as a configuration option but remember all configuration options must be able to change at any time (mutability). I have used some template technologies to put charm configuration options in places where the script would prompt users.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">So I'm thinking one obvious way would be to just have some sed and awk
steps to just change the oracle-xe script to just non-interactively use
the default ports</blockquote><div>Make the ports configurable, so that you can deploy the service and know the port where it is being served. The user could change it if they know that port is being used.<br><br></div><div>Database charms are the most complex for *me* to understand, but I encourage you to look at the "mysql" charm for tips on database. It was written by one of our best charmers who knows how to install databases. You will find many answers to your questions in that charm.<br><br></div><div>If you have any further questions please share them with <a href="mailto:juju@lists.ubuntu.com">juju@lists.ubuntu.com</a> so the whole community has the benefit of the information, and other database charmers can pipe in. <br></div> </div></div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font size="2"> - Matt Bruzek <<a href="mailto:matthew.bruzek@canonical.com" target="_blank">matthew.bruzek@canonical.com</a>></font><br></div></div></div></div></div>
<br><div class="gmail_quote">On Fri, Mar 4, 2016 at 1:36 PM, Gilbert Standen <span dir="ltr"><<a href="mailto:gilstanden@hotmail.com" target="_blank">gilstanden@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div dir="ltr">Hey I'm sorry to bug you with another question but I'm trying to find my way along to get through creating my first charm.<br><br>Because Oracle-XE 11gR2 version requires accepting a license agreement to download from Oracle.com (adding a level of complexity to creating my first charm) I stepped back even further to Oracle-XE 10gR2 which actually is still available from a DEB repository. I realize 10gR2 is pretty old but for purposes of learning how to charm, it's great, because it's available from a ppa still and it's pretty easy to deploy from a manual steps perspective, so it should be a good "first charm" exercise for me.<br><br>So my install hook is taking shape kinda like this (and works):<br><br># GLS start <br>echo 'deb <a href="http://oss.oracle.com/debian/" target="_blank">http://oss.oracle.com/debian/</a> unstable main non-free' | sudo tee --append /etc/apt/sources.list <br>echo 'deb-src <a href="http://oss.oracle.com/debian/" target="_blank">http://oss.oracle.com/debian/</a> unstable main' | sudo tee --append /etc/apt/sources.list <br>wget <a href="http://oss.oracle.com/el4/RPM-GPG-KEY-oracle" target="_blank">http://oss.oracle.com/el4/RPM-GPG-KEY-oracle</a> -O- | sudo apt-key add - <br>apt-get update<br>apt-get install -y oracle-xe --force-yes<br># GLS end<br><br>all of the above works great. However, oracle-xe has a configuration script that has to be run at this point (as many db's do) which sets some ports and the admin password. That script comes with it and is '/etc/init.d/oracle-xe" and it is run interactively (typically) as shown below:<br><br>/etc/init.d/oracle-xe configure<br><br>which goes like this (interactively):<br><br>--- snip start----<br><br>root@W520:/etc/init.d# ./oracle-xe configure<br><br>Oracle Database 10g Express Edition Configuration<br>-------------------------------------------------<br>This will configure on-boot properties of Oracle Database 10g Express <br>Edition. The following questions will determine whether the database should <br>be starting upon system boot, the ports it will use, and the passwords that <br>will be used for database accounts. Press <Enter> to accept the defaults. <br>Ctrl-C will abort.<br><br>Specify the HTTP port that will be used for Oracle Application Express [8080]: <br><br>Specify a port that will be used for the database listener [1521]:<br><br>Specify a password to be used for database accounts. Note that the same<br>password will be used for SYS and SYSTEM. Oracle recommends the use of <br>different passwords for each database account. This can be done after <br>initial configuration:<br>Confirm the password:<br><br>Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]:<br><br>Starting Oracle Net Listener...Done<br>Configuring Database...Done<br>Starting Oracle Database 10g Express Edition Instance...Done<br>Installation Completed Successfully.<br>To access the Database Home Page go to "<a href="http://127.0.0.1:8080/apex" target="_blank">http://127.0.0.1:8080/apex</a>"<br>root@W520:/etc/init.d# <br><br>---snip end---<br><br>My question is, what is the best way to automate this last step for charm deployment? One way would be for me to just do some kind of sed or awk and replace the interactive steps in the /etc/init.d/oracle-xe script to just use the default values and to use some hardcoded default password. <br><br>However, the script does some checking to verify that the default ports of 8080 and 1521 are not already in use which again would involve some interactive steps, which pretty much we don't want in a charm, correct?.<br><br>So I guess what I am wondering is what is the best way to handle these kind of configuration steps. I downloaded the couchdb charm, and it has steps like this which look like they are doing similar config steps (all the stuff starting with DEFAULT_ADMIN_PASSWORD for example:<br><br>---snip start---<br><br>apt-get install -y couchdb facter facter-customfacts-plugin uuid python-couchdb pwgen<br><br>DEFAULT_ADMIN_PASSWORD=`pwgen -N1`<br>DEFAULT_REPLICATION_PASSWORD=`pwgen -N1`<br><br>fact-add couchdb_hostname `facter fqdn`<br>fact-add couchdb_ip `facter ipaddress`<br>fact-add couchdb_port 5984<br>fact-add couchdb_replication ${DEFAULT_REPLICATION_PASSWORD}<br>fact-add couchdb_admin ${DEFAULT_ADMIN_PASSWORD}<br><br>sed -i.bak -e "s/bind_address =.*/bind_address = `facter couchdb_ip`/" /etc/couchdb/default.ini<br>sed -i.bak -e "s/;port =.*/port = `facter couchdb_port`/" \<br> -e "s/;bind_address.*/bind_address = `facter couchdb_ip`/" \<br> -e "s/; require_valid_user = false/require_valid_user = true/" \<br> -e "s/;admin =.*/admin = ${DEFAULT_ADMIN_PASSWORD}/" \<br> /etc/couchdb/local.ini<br><br>echo "replication = ${DEFAULT_REPLICATION_PASSWORD}" >> /etc/couchdb/local.ini<br><br>service couchdb status && service couchdb restart || service couchdb start<br><br>open-port `facter couchdb_port`/TCP<br><br>---snip stop---<br><br>So I'm thinking one obvious way would be to just have some sed and awk steps to just change the oracle-xe script to just non-interactively use the default ports, but I'd still have to pass in the default passwords for SYS and SYSTEM.<br><br>Any pointers to some documentation on different ways to solve this type of challenge would be helpful.<br><br>Thanks,<br><br>Gilbert<br> </div></div>
</blockquote></div><br></div></div>