installing tomcat7 using puppet on CentOs - solr

so my idea was to install tomcat7 using puppet, and then deploy the war file of Solr as a web app. Here is what i found.
There are many tomcat7 modules on puppet forge but none of them work out of box, and i am not sure if any of them actually work and a lot of them pertains to have code as documentation.
Take puppet module install fhuertas-tomcat7 as first example:
installs fhuertas-tomcat7 (v0.0.1)
i get an error, when i run:
sudo puppet apply --modulepath=/home/qa/puppet_qa/modules/ -e "include tomcat7" --debug
Error: Could not find data item service_path in any Hiera data file and no default supplied
and similar scenario follows for :
puppet module install llehmijo-tomcat7_rhel ( no longer maintained )
https://github.com/Spredzy/puppet-tomcat7 ( claims to be for CentOs ) but has an Apt (apt for centos ??) pre-requisite, plus it did not install either.
All i want to do is to install tomcat7 via puppet, and then install Solr. seems to be a simple request. Meanwhile i am working on my own to resolve the exact issue, and was able to install and run tomcat7, but not sure how i can install tomcat-users.xml
here is a portion of my init.pp
exec {'start service':
command => 'sh "startup.sh"',
cwd => "/usr/share/apache-tomcat-7.0.42/bin",
path => '/usr/share/apache-tomcat-7.0.42/bin/:/usr/bin:/bin',
#require => File['/usr/share/apache-tomcat-7.0.42/conf/tomcat-users.xml']
}
so if i un-comment the require => File[]
Error: Could not find dependency File[/usr/share/apache-tomcat-7.0.42/conf/tomcat-users.xml] for Exec[start service]

file { "/etc/tomcat7/tomcat-users.xml":
owner => 'root',
require => Package['tomcat'],
notify => Service['tomcat'],
content => template('tomcat/tomcat-users.xml.erb')
}
This works, as for the modules not working on puppet forge , and github, i think there is no resolution as if not working then these modules can be taken as guidelines, or hints.

I used the supported one https://forge.puppetlabs.com/puppetlabs/tomcat and following the examples everything was properly installed using packages (at least on Ubuntu). It is also possible to install it from source.
https://github.com/puppetlabs/puppetlabs-tomcat/tree/master/examples. See the example below:
class { 'java': }
class { 'tomcat':
install_from_source => false,
user => 'tomcat7',
require => Class['java']
}
tomcat::instance { 'tomcat7':
package_name => 'tomcat7',
require => Class['tomcat']
}->
tomcat::instance { 'tomcat7-admin':
package_name => 'tomcat7-admin',
}->
tomcat::config::server::tomcat_users {
'tomcat-admin':
catalina_base => '/var/lib/tomcat7',
element => 'user',
password => 'test',
roles => ['manager-gui','admin'];
'deployer':
catalina_base => '/var/lib/tomcat7',
element => 'user',
password => 'deployer',
roles => ['manager-script'];
}->
tomcat::service { 'tomcat7':
service_ensure => running,
catalina_base => '/var/lib/tomcat7',
require => Tomcat::Instance['tomcat7']
}

Related

Guys i am getting error as below while copying the file from puppet master to agents

1.when i used "puppet agent -t" command in agents it's not retrieving from puppet server and getting the error as below.
2.the below code i have used in modules path:/etc/puppetlabs/code/environments/production/modules/mailx/manifests/init.pp and i have included this class in site.pp file as below.
Error: 1.I
/Stage[main]/Mailx/File[/etc/mail.rc]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/mailx/mail.rc
file { '/etc/mail.rc':
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
source => 'puppet:///modules/mailx/mail.rc',
}
node 'default', {
include mailx
}
Your code will be much easier to read if you present it like this.
#/etc/puppetlabs/code/environments/production/modules/init.pp
class mailx {
file { '/etc/mail.rc':
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
source => 'puppet:///modules/mailx/mail.rc',
}
}
And then the file
#/etc/puppetlabs/code/environments/production/modules/mailx/files/mail.rc
set smtp=your.smtp.server
set from="from email address"
The module should be in
/etc/puppetlabs/code/environments/production/modules/mailx/manifests/init.pp
Notice the "production" after the environments.
It may have just been a typo when you put the path in to here but you spelt puppetlabs as puppelabc.
And the file should be here
/etc/puppetlabs/code/environments/production/modules/mailx/files/mail.rc
Each directory under the environment directory is an environment and that error says Puppet is looking in the production environment for that file.

Configure DDEV with Apache Solr on Drupal 7 for Search API

From #DamienMcKenna in Slack
Having problems creating a Solr instance with a D7 site. I copied the conf files to ~/.ddev/solr/conf but when Solr starts there is no default instance created. I ran ddev stop --remove-data --omit-snapshot and recreated the instance, but the instance still doesn't exist. When I go to the Solr UI to check the system it shows "no cores available", when I try to create one named "dev" it says:
Error CREATEing SolrCore 'dev': Unable to create core [dev] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/opt/solr/server/solr/dev'
I had success on a Drupal 7 project using the example docker-compose-solr.yaml file from version 1.11.0 of DDEV.
Copy https://github.com/drud/ddev/blob/v1.11.0/pkg/servicetest/testdata/services/docker-compose.solr.yaml into your .ddev folder and ensure line 34 matches the solr version you're going to copy from step 2 below, eg solr: 6.6
Copy the files from sites/all/modules/contrib/search_api_solr/solr-conf/6.x/*.* into the .ddev/solr/conf folder.
Download and enable search_api_override module.
Add the following in settings.local.php:
// For ddev only.
$conf['search_api_override_mode'] = 'load';
$conf['search_api_override_servers']['content'] = array(
'name' => 'DDEV: Solr Server',
'options' => array(
'host' => 'solr',
'port' => '8983',
'path' => '/solr/dev',
'http_user' => '',
'http_pass' => '',
'excerpt' => 0,
'retrieve_data' => 1,
'highlight_data' => 0,
'http_method' => 'AUTO',
),
);
Also, ymmv. It may be better to only override the values you need individually… a la:
$conf['search_api_override_servers']['content']['options']['host'] = 'solr';
$conf['search_api_override_servers']['content']['options']['port'] = '8983';
$conf['search_api_override_servers']['content']['options']['host'] = '/solr/dev';
You may need to modify 'content' array index to match whatever you configured in Drupal 7 to be your Solr index's machine name.
Start ddev with ddev start.
NOTE, I place the Search API override values in sites/default/settings.local.php instead of what one would think to be the logical place (sites/default/settings.ddev.php) so as not to interfere with DDEV's own auto-generation of the latter file.
It would be cool if DDEV did this automatically in settings.ddev.php similar to how the DB service settings work, but AFAICT this level of integration is not there and likely never will be for Drupal 7. Firstly, because you need an additional module (search_api_override) that may or may not be present, and secondly because users have the ability to name their Solr server whatever they want, so it would be hard to automate that. E.g. $conf['search_api_override_servers']['content'] could be anything like: $conf['search_api_override_servers']['foo'].

How to install a plugin manually in CakePHP 3?

I am unable to use Composer and thus have to install CakePDF plugin manually, but following examples from official CakePHP documentation does not seem to work.
So here is installation flow that I have followed:
1.) Copied the plugin to app/plugins/CakePdf
2.) Updated the app's composer.json file, like following:
"autoload": {
"psr-4": {
"CakePdf\\": "./plugins/CakePdf/src",
"CakePdf\\Test\\": "./plugins/CakePdf/tests"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
"CakePdf\\": "./plugins/CakePdf/src",
"CakePdf\\Test\\": "./plugins/CakePdf/tests"
}
}
3.) Loaded the plugin in bootstrap.php:
Plugin::load('CakePdf', ['bootstrap' => true, 'routes' => true, 'autoload' => true]);
4.) Added router extensions:
Router::extensions(['pdf']);
5.) Tried a very simple sample from plugin's doc:
$cakePdf = new CakePdf(array(
'engine' => 'CakePdf.DomPdf',
'pageSize' => 'A4',
'orientation' => 'portrait'
));
$html = '<html><head><body><p>Pdftest</p></body></head></html>';
$rawPdf = $CakePdf->output($html);
However the code breaks at the first line and the following error message is provided:
Class 'App\Controller\CakePdf' not found
I would really appreciate any help or guidance for how a plugin should be installed manually.
If there is any other information that I need to provide, just ask.
You are getting this error because inside vendor/composer/ you can see some autoload_*.php files. These files hold the paths to load your classes. I think no one can safely tell you what to update and where in these files.
So you have two solutions:
1 - Copy composer.json on a local machine and run composer update. Then move the files created inside your app. I would suggest to take a backup before. Most probably the things that you will have to move are:
vendor/
composer.json
composer.lock
2 - Start updating the files inside vendor/composer/autoload_*.php with the paths from the plugin. Most probably you will only need to update the following two files:
vendor/cakephp-plugins.php and vendor/composer/autoload_psr4.php. Personally I wouldn't choose the second solution I am just adding it as an alternative just in case.

Unexpected error communicating with Stripe

Billing with Stripe i have a form and i submit information and place the order following error has occured....
Unexpected error communicating with Stripe. If this problem persists, let us know at support#stripe.com. (Network error [errno 77]: error setting certificate verify locations: CAfile: C:\xampp\htdocs\PhpProject2\app\Lib\Stripe/../data/ca-certificates.crt CApath: none )
my controller action code
if(!empty($this->request->data)){
$email = $this->request->data['email'];
$credit_card = $this->request->data['card_number'];
$expire_month = $this->request->data['expiration_month'];
$expire_year = $this->request->data['expiration_year'];
$cvc = $this->request->data['cvc'];
//require_once('./lib/Stripe.php');
require_once "./../lib/Stripe.php";
Stripe::setApiKey("sk_test_KEY");
$token = Stripe_Token::create(array(
"card" => array(
"number" => $credit_card,
"exp_month" => $expire_month,
"exp_year" => $expire_year,
"cvc" => $cvc)));
and my view
<?php
echo $this->Form->create(false, array('action' => 'index'));
echo $this->Form->input('email', array('id' => 'email'));
echo $this->Form->input('card_number');
$options = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April',
'5' =>'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September',
'10' => 'October',
'11' => 'November', '12' => 'December');
$start_year =array('1'=>2013,'2'=>2014,'3'=>2015,'4'=>2016,
'5'=>2017,'6'=>2018,'7'=>2019,'8'=>2020,'9'=>2021);
echo $this->Form->input('expiration_month', array('type' => 'select', 'options' => $options));
echo $this->Form->input('cvc');
echo $this->Form->end('place order', array('controller' => 'stripes', 'action' => 'index'));
?>
any help will appreciated
You will get this error if you do not have your CA bundle configured correctly.
You can use the following before making your charge calls to get around this.
\Stripe\Stripe::setVerifySslCerts(false);
This will leave your traffic, including client PII, vulnerable to interception and/or tampering.
Disabling SSL Certificates verification (\Stripe\Stripe::setVerifySslCerts(false); suggested by ykay) was useful to me in a test/local environment, but in production this verification still needs to happen.
So I contacted Stripe support and they suggested me a few steps (explained below) that finally led me to the real problem, my file structure:
data/ca-certificates.crt is referenced by Stripe.php's getDefaultCABundlePath(). If this file is not found, you might get an ApiConnection error with empty properties as output, like the one posted in this other question.
So the solution was either simply to place this file exactly on that path, or to move it to a different directory and update its location using Stripe::setCABundlePath().
If all Stripe files are properly referenced: steps for verifying TLSv1.2 support
Testing TLS in the server: after ensuring TLSv1.2 was operational in the server through this script that Stripe support recommended, producing the following output:
TLS test (default): TLS 1.2
TLS test (TLS_v1): TLS 1.2
TLS test (TLS_v1_2): TLS 1.2
They then suggested me to check for compatibility issues:
https://github.com/stripe/stripe-php#ssl--tls-compatibility-issues
This lead me to run the script in upgrade cURL and OpenSSL packages which tests and uses the Stripe's PHP integration (requires Stripe's init.php code):
https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php
The following was produced:
TLS 1.2 is not supported. You will need to upgrade your integration.
Since the server is running Ubuntu (cat /etc/*-release) I then upgraded the OpenSSL version:
https://support.stripe.com/questions/how-do-i-upgrade-my-openssl-to-support-tls-1-2
With the following commands:
sudo apt-get update && sudo apt-get install --only-upgrade openssl
sudo apt-get update && sudo apt-get install --only-upgrade libssl-dev
Since these packages were in their latest version in the server, I decided to have another look into the Stripe's zip file structure and found out that when I unzipped the files, the path to ca-certificates.crt was not the same as the one in Stripe.php (which was causing the issue).
Not sure, but your code might be working. The issue is they require encrypted communication accomplished by certificate files which you either haven't set (in the library itself, SDKs often work like this) when using the library or the path is unparseable (mixed forward / and back \ slashes).

Cake PHP not building Models

I have created my database, and used cake bake my_project to create my project, and now when I try cake bake all form within my project directory, I get an error relating to Mysql. When I view my project from the browser, it all lights up green, including connecting to the database.
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/billy/Documents/projects/cakephp/lib/Cake/Model/Datasource/Database/Mysql.php, line 160]
Any ideas as to what this error is about?
EDIT: Added relevant configuration details (php --info |grep mysql)
I don't really know what to look for in here, but maybe someone does...
$ php --info |grep mysql
Configure Command => '/var/tmp/apache_mod_php/apache_mod_php-53.3.1~2/php/configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--sysconfdir=/private/etc' '--with-apxs2=/usr/sbin/apxs' '--enable-cli' '--with-config-file-path=/etc' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/BinaryCache/apache_mod_php/apache_mod_php-53.3.1~2/Root/usr/local' '--with-png-dir=/BinaryCache/apache_mod_php/apache_mod_php-53.3.1~2/Root/usr/local' '--enable-gd-native-ttf' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-iodbc=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte' '--enable-zip' '--with-pcre-regex=/usr'
mysql
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
mysql.allow_local_infile => On => On
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off
mysqli
Client API library version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqlnd
mysqlnd => enabled
Version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
PDO drivers => mysql, sqlite, sqlite2
pdo_mysql
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
pdo_mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
Edit: More info
I tried the suggestion from #0k32, but unfortunately it did not work for me. I soft linked php from my XAMPP folder to /usr/bin/php, and checked it was the right one with which php. I then did a php --info | grep sock and got:
MYSQL_SOCKET => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
mysql.default_socket => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
MYSQLI_SOCKET => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
mysqli.default_socket => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock => /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Which seems to suggest that the correct version of MySQL is being activated. Still I am getting exactly the same error.
I think this issue could appear because of different configuration files (php.ini) used by apache's php module and command line php. Default settings for mysql connections may differ in those configs.
Compare phpinfo() output from apache and php --info from command line.
Update:
In your case it seems you are on MacOS and are using MAMP/MAMP PRO. So am I. And I had the same problem.
My solution was very simple. I replaced default php cli binary with a symlink to MAMP's php binary:
$ sudo mv /usr/bin/php /usr/bin/php_default
$ sudo ln -s /Applications/MAMP/bin/php/php5.3.6/bin/php /usr/bin/php
MAMP's php is connecting to MySQL via /Applications/MAMP/tmp/mysql/mysql.sock by default and MacOS's default command line php is trying to use /var/mysql/mysql.sock.
Anyway I think it's a good practice to use the same php with the same config for both web and cli.
update:
A smarter solution would be not to replace default php but just add path to MAMP's php binaries to the PATH. So in your ~/.bash_profile:
export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:$PATH
Correct it if needed.
Then reopen terminal or execute this: source ~/.bash_profile. Then you can check which php you are using by executing which php. It should point to MAMP's php.

Resources