I'm using PuPHPet/Puppet/Vagrant to set up a VM with nginx and postgresql. I'd like to be able to connect to the postgresql database with a GUI. I don't know the required steps to set this up though.
I think i need to forward port 5432 to 5432 on my local machine and then edit the pg_hba.conf to allow for outside connections but i don't know what that needs to look like.
Here's my current Vagrantfile(doesn't have the port forward)
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "10.10.10.10"
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 1024]
v.customize ["modifyvm", :id, "--name", "NGINX_PostgreSQL"]
end
config.vm.synced_folder "./", "/var/www", id: "vagrant-root"
config.vm.provision :shell, :inline =>
"if [[ ! -f /apt-get-run ]]; then sudo apt-get update && sudo touch /apt-get-run; fi"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "vagrant/manifests"
puppet.module_path = "vagrant/modules"
puppet.options = ['--verbose']
end
end
Here's my default.pp file
group { 'puppet': ensure => present }
Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
File { owner => 0, group => 0, mode => 0644 }
class {'apt':
always_apt_update => true,
}
Class['::apt::update'] -> Package <|
title != 'python-software-properties'
and title != 'software-properties-common'
|>
apt::key { '4F4EA0AAE5267A6C': }
apt::ppa { 'ppa:ondrej/php5-oldstable':
require => Apt::Key['4F4EA0AAE5267A6C']
}
class { 'puphpet::dotfiles': }
package { [
'build-essential',
'vim',
'curl',
'git-core'
]:
ensure => 'installed',
}
class { 'nginx': }
nginx::resource::vhost { 'mylaravel.com':
ensure => present,
server_name => [
'mylaravel.com' ],
listen_port => 80,
index_files => [
'index.html',
'index.htm',
'index.php'
],
www_root => '/var/www/public',
try_files => ['$uri', '$uri/', '/index.php?$args'],
}
$path_translated = 'PATH_TRANSLATED $document_root$fastcgi_path_info'
$script_filename = 'SCRIPT_FILENAME $document_root$fastcgi_script_name'
nginx::resource::location { 'mylaravel.com-php':
ensure => 'present',
vhost => 'mylaravel.com',
location => '~ \.php$',
proxy => undef,
try_files => ['$uri', '$uri/', '/index.php?$args'],
www_root => '/var/www/public',
location_cfg_append => {
'fastcgi_split_path_info' => '^(.+\.php)(/.+)$',
'fastcgi_param' => 'PATH_INFO $fastcgi_path_info',
'fastcgi_param ' => $path_translated,
'fastcgi_param ' => $script_filename,
'fastcgi_param ' => 'APP_ENV dev',
'fastcgi_param ' => 'APP_DBG true',
'fastcgi_pass' => 'unix:/var/run/php5-fpm.sock',
'fastcgi_index' => 'index.php',
'include' => 'fastcgi_params'
},
notify => Class['nginx::service'],
}
class { 'php':
package => 'php5-fpm',
service => 'php5-fpm',
service_autorestart => false,
config_file => '/etc/php5/fpm/php.ini',
module_prefix => ''
}
php::module {
[
'php5-pgsql',
'php5-cli',
'php5-curl',
'php5-intl',
'php5-mcrypt',
'php-apc',
]:
service => 'php5-fpm',
}
service { 'php5-fpm':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
require => Package['php5-fpm'],
}
class { 'php::devel':
require => Class['php'],
}
class { 'xdebug':
service => 'nginx',
}
class { 'composer':
require => Package['php5-fpm', 'curl'],
}
puphpet::ini { 'xdebug':
value => [
'xdebug.default_enable = 1',
'xdebug.remote_autostart = 0',
'xdebug.remote_connect_back = 1',
'xdebug.remote_enable = 1',
'xdebug.remote_handler = "dbgp"',
'xdebug.remote_port = 9000'
],
ini => '/etc/php5/conf.d/zzz_xdebug.ini',
notify => Service['php5-fpm'],
require => Class['php'],
}
puphpet::ini { 'php':
value => [
'date.timezone = "America/Chicago"'
],
ini => '/etc/php5/conf.d/zzz_php.ini',
notify => Service['php5-fpm'],
require => Class['php'],
}
puphpet::ini { 'custom':
value => [
'display_errors = On',
'error_reporting = -1'
],
ini => '/etc/php5/conf.d/zzz_custom.ini',
notify => Service['php5-fpm'],
require => Class['php'],
}
class { 'postgresql':
charset => 'UTF8',
locale => 'en_US.UTF-8',
}->
class { 'postgresql::server':
config_hash => {
postgres_password => 'root',
},
}
postgresql::db { 'appDB':
user => 'dadams',
password => 'mypassword',
grant => 'ALL',
}
and here's my pg_hba.conf file inside the VM
# This file is managed by Puppet. DO NOT EDIT.
# Rule Name: local access as postgres user
# Description: none
# Order: 001
local all postgres ident
# Rule Name: local access to database with same name
# Description: none
# Order: 002
local all all ident
# Rule Name: deny access to postgresql user
# Description: none
# Order: 003
host all postgres 0.0.0.0/0 reject
# Rule Name: allow access to all users
# Description: none
# Order: 100
host all all 127.0.0.1/32 md5
# Rule Name: allow access to ipv6 localhost
# Description: none
# Order: 101
host all all ::1/128 md5
Most GUIs will allow you to connect via an SSH tunnel. This is the best way to do what you want.
Add the following port forwarding rule in Vagrantfile and do a vagrant reload, see if you can connect to the postgresql.
config.vm.network :forwarded_port, guest: 5432, host:5432
NOTE: you may still need to change postgresql.conf listen_addresses (bind) to * (all) interfaces and allow client connections from certain networks by modifying host records in the pg_hba.conf file.
Sample allow connection from network 10.1.1.0/24 unconditionally
host all all 10.1.1.0/24 trust
I think in your use case, enabling a 2nd network interface (public network) will make life easier, avoid lots of port forwarding and network issue.
Related
I am trying to query an additional external database connection in one of my repositories. In LocalConfiguration.php I've defined two connections (Default, External).
[...]
'DB' => [
'Connections' => [
// Local MySQL database
'Default' => [
// ...
],
// External MSSQL database
'External' => [
'charset' => 'utf-8',
'dbname' => 'DBNAME',
'driver' => 'sqlsrv',
'host' => 'someExternalIP',
'password' => 'somePassword',
'port' => 1433,
'user' => 'someUser',
],
],
],
[...]
In my repository I want to query the external database (via Doctrine).
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('dbo.SomeTable');
$queryBuilder->getRestrictions()->removeAll();
$queryBuilder
->select('*')
->from('dbo.SomeTable');
Do I have to explicitly tell the QueryBuilder to use that particular connection? Right now I am getting an Doctrine\DBAL\Exception\ConnectionException error, as the system tries to connect via the Default-Connection.
An exception occurred while executing 'SELECT * FROM `dbo`.`SomeTable`':
SELECT command denied to user 'myLocalUser'#'localhost' for table 'SomeTable'
Check out $GLOBALS['TYPO3_CONF_VARS']['DB']['TableMapping'] where you can explicitly define what tables are located in which database. See also this for some more details https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Database/Configuration/Index.html
The other option is actually to use ask the Connection by name, and create a query builder out of that.
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionByName('External')->createQueryBuilder(...)
I personally would go with the latter, as it is more explicit within the actual callers code what is used.
To work with external DB, you have to :
configure the mapping with external database and table mapping in LocalConfiguration.php
define the TCA for external tables in myExt/Configuration/TCA/MyExternalTableName.php
configure the external tables/columns mapping in ext_typoscript_setup.txt
and then, the queries in repositories will work.
Sample LocalConfiguration.php :
'DB' => [
'Connections' => [
'Default' => [
'charset' => 'utf8',
'dbname' => 'LOCAL-DB',
'driver' => 'mysqli',
'host' => '127.0.0.1',
'password' => 'PWD',
'port' => 3306,
'user' => 'USER',
],
'externalDb' => [
'charset' => 'utf8',
'dbname' => 'EXTERNAL-DB',
'driver' => 'mysqli',
'host' => 'localhost',
'password' => 'PWD',
'port' => 3306,
'user' => 'USER',
],
],
'TableMapping' => [
'MyexternalTable1' => 'externalDb',
'MyexternalTable2' => 'externalDb',
...
]
]
Sample columns mapping in myExt/ext_typoscript_setup.txt :
plugin.tx_myext {
persistence {
classes {
Vendor\MyExt\Domain\Model\LocalModel {
mapping {
tableName = ExternalTableName
recordType = \Vendor\MyExt\Domain\Model\LocalModel
columns {
col1.mapOnProperty = uid
col2.mapOnProperty = name
...
}
}
}
}
}
}
I want to check one of our DB2 database's table via logstash but I got this exception.
[2018-02-06T13:34:34,175][ERROR][logstash.agent ] Pipeline aborted due to error {:exception=>#, :backtrace=>["com.ibm.as400.access.JDError.createSQLExceptionSubClass(com/ibm/as400/access/JDError.java:824)", "com.ibm.as400.access.JDError.throwSQLException(com/ibm/as400/access/JDError.java:553)", "com.ibm.as400.access.AS400JDBCConnection.setProperties(com/ibm/as400/access/AS400JDBCConnection.java:3391)", "com.ibm.as400.access.AS400JDBCDriver.prepareConnection(com/ibm/as400/access/AS400JDBCDriver.java:1419)", "com.ibm.as400.access.AS400JDBCDriver.initializeConnection(com/ibm/as400/access/AS400JDBCDriver.java:1256)", "com.ibm.as400.access.AS400JDBCDriver.connect(com/ibm/as400/access/AS400JDBCDriver.java:395)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)",
this is my input config
input {
beats {
port => 5044
ssl => true
ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"
ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"
}
jdbc {
jdbc_connection_string => "jdbc:as400://ip/db"
jdbc_user => "usr"
jdbc_password => "pass"
jdbc_driver_library => "/etc/logstash/lib/jt400-9.1.jar"
jdbc_driver_class => "com.ibm.as400.access.AS400JDBCDriver"
statement => "SELECT * FROM table1 FETCH FIRST ROWS ONLY"
}
}
I have to mention that the firewall inside of the Database have been disabled.
I have a working ruby script that we have been using for a quite a while to order VSIs from SoftLayer. The script specifies a certain price item for CPU, one for memory, and another for disk. I am trying to modify the script to work with flavors but I have been unable to figure out what I am doing wrong. Basically I have removed the CPU, memory, and disk price items from the product order and added in a flavorKeyName in the supplementalCreateObjectOptions like this:
#!/usr/bin/ruby
require 'softlayer_api'
client = SoftLayer::Client.new(username: 'XXXXX', api_key: 'XXXXX')
productOrder = {
'virtualGuests' => [{
'hostname' => 'test',
'domain' => 'mycompany.com',
'primaryNetworkComponent' => { 'networkVlan' => { 'id' => XXXXXX } },
'primaryBackendNetworkComponent' => { 'networkVlan' => { 'id' => XXXXXX },
'supplementalCreateObjectOptions' => { 'flavorKeyName' => 'B1_1X2X100' } }
}],
'location' => XXXXXX,
'packageId' => 46,
'imageTemplateId' => XXXXX,
'useHourlyPricing' => true,
'prices' => [
{'id' => 34183 }, # 0 GB Bandwidth
{'id' => 24713 }, # 1 Gbps Public & Private Network Uplinks
{'id' => 34807 }, # 1 IP Address
{'id' => 33483 }, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
{'id' => 34241 }, # Host Ping and TCP Service Monitoring
{'id' => 32500 }, # Email and Ticket
{'id' => 35310 }, # NESSUS_VULNERABILITY_ASSESSMENT_REPORTING
{'id' => 23070 }, # REBOOT_REMOTE_CONSOLE
{'id' => 32627 } # AUTOMATED_NOTIFICATION
]
}
order = client['Product_Order'].verifyOrder(productOrder)
but this fails with:
/usr/lib64/ruby/2.1.0/xmlrpc/client.rb:271:in `call': Internal Error (XMLRPC::FaultException)
from /usr/lib64/ruby/gems/2.1.0/gems/softlayer_api-3.2.2/lib/softlayer/Service.rb:269:in `call_softlayer_api_with_params'
from /usr/lib64/ruby/gems/2.1.0/gems/softlayer_api-3.2.2/lib/softlayer/Service.rb:198:in `method_missing'
from /tmp/yy2:34:in `<main>'
The error is not too helpful on what I might be specifying incorrectly or might be missing.
Does any one have a suggestions on what I might be doing wrong?
When using Softlayer_Product_Order::verifyOrder or Softlayer_Product_Order::placeOrder you need to use the package 835, and set the presetId parameter to specify what flavor configuration you want to order.
The supplementalCreateObjectOptions parameter is specified when using the SoftLayer_Virtual_Guest::createObject method.
Following are two ways to order virtual guest devices with a flavor configuration.
PlaceOrder
To get the list of available preset ids for package 835 you need to use the method SoftLayer_Product_Package::getActivePresets.
https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/835/getActivePresets
Check the keyName values to know which are Balanced, Memory, etc., they should start with:
B1 is for "Balanced"
BL1 is for "Balanced Local Storage"
BL2 is for "Balanced Local Storage - SSD"
C1 is for "Compute"
M1 is for "Memory"
These characters are followed by a short description of VSI configuration as following:
C1_2X2X100 for Compute VSI with "2 x 2.0 GHz Cores, 2 GB RAM, 100 GB Disk"
B1_8X16X25 for Balanced VSI with "8 x 2.0 GHz Cores, 16 GB RAM, 25 GB Disk"
If I'm not wrong the presetId 333 is for B1_1X2X100 which is the flavor configuration you want.
require 'rubygems'
require 'softlayer_api'
require 'json'
# Your SoftLayer API username and API Key.
USERNAME = 'set-me'
API_KEY = 'set-me'
# Location where server will be provisioned.
location = 'AMSTERDAM03'
# The id of the SoftLayer_Product_Package, use the 835 for VSI Families.
package_id = 835
# Following is the preset id used to complete this example.
preset_id = 333 # B1_1X2X100 (1 x 2.0 GHz Cores, 2 GB RAM, and primary disk of 25 GB)
# The number of servers you wish to order in this configuration.
quantity = 1
# Build a skeleton SoftLayer_Virtual_Guest object. If you set quantity greater than 1
# then you need to define one hostname/domain per server you wish to order.
virtual_guest = [
{
'hostname' => 'test-vsi',
'domain' => 'mycompany.com',
'primaryNetworkComponent' => { 'networkVlan' => { 'id' => 11111 } },
'primaryBackendNetworkComponent' => { 'networkVlan' => { 'id' => 22222 }}
}
]
# Specify the item prices. Note that you don't need to specify the item price for
# cpus, ram, and primary disk, and take into account that “Balanced Local Storage”
# and “Balanced Local Storage - SSD” requires a second disk, the system will select one
# if you don’t specify it.
prices = [
{'id' => 34183 }, # 0 GB Bandwidth
{'id' => 24713 }, # 1 Gbps Public & Private Network Uplinks
{'id' => 34807 }, # 1 IP Address
{'id' => 33483 }, # Unlimited SSL VPN Users & 1 PPTP VPN User per account
{'id' => 34241 }, # Host Ping and TCP Service Monitoring
{'id' => 32500 }, # Email and Ticket
{'id' => 35310 }, # NESSUS_VULNERABILITY_ASSESSMENT_REPORTING
{'id' => 23070 }, # REBOOT_REMOTE_CONSOLE
{'id' => 32627 } # AUTOMATED_NOTIFICATION
]
# Build a skeleton SoftLayer_Container_Product_Order object containing the order
# you wish to place.
order_template = {
'quantity' => quantity,
'location' => location,
'packageId' => package_id,
'presetId' => preset_id,
'imageTemplateId' => 1111111,
'useHourlyPricing' => true,
'prices' => prices,
'virtual_guest' => virtual_guest
}
# Declare the API client to use the SoftLayer_Product_Order API service
client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
product_order_service = client.service_named('SoftLayer_Product_Order')
begin
# verifyOrder() will check your order for errors. Replace this with placeOrder()
# when you're ready to order.
receipt = product_order_service.verifyOrder(order_template)
puts JSON.pretty_generate(receipt)
rescue StandardError => exception
puts "There was an error in your order: #{exception}"
end
CreateObject
Take account that createObject method is a simplified way to order virtual guest devices so you may not be able to set items like IPV6, secondary IP address, etc. See SoftLayer_Virtual_Guest::createObject to know which properties you can set.
The following example is to order a vsi family with flavor configuration B1_1X2X100, on this case it is necessary to set the parameter supplementalCreateObjectOptions
require 'rubygems'
require 'softlayer_api'
require 'json'
# Your SoftLayer API username and API Key.
USERNAME = 'set-me'
API_KEY = 'set-me'
# Build the skeleton of SoftLayer_Virtual_Guest object.
virtual_guest_template = {
'hostname' => 'test-vsi',
'domain' => 'mycompany.com',
'primaryNetworkComponent' => { 'networkVlan' => { 'id' => 11111 } },
'primaryBackendNetworkComponent' => { 'networkVlan' => { 'id' => 22222 }},
'datacenter' => { 'name' => 'dal05' },
'supplementalCreateObjectOptions' => {
'flavorKeyName' => 'B1_1X2X100'
},
'hourlyBillingFlag' => true,
# Following is to specify the imageTemplate you want to use. But on this case you need
# to set the globalIdentifier of imageTemplate.
'blockDeviceTemplateGroup' => {
'globalIdentifier' => '6x06c3x8-4158-4b69-ba5x-433c18x3xac3'
},
'networkComponents' => [
{ 'maxSpeed' => 1000} # 1 Gbps Public & Private Network Uplinks
]
}
# Declare the API client to use the SoftLayer_Virtual_Guest API service
client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
virtual_guest_service = client['SoftLayer_Virtual_Guest']
begin
# Call to createObject() when you're ready to order.
# Call to generateOrderTemplate() if you want to create an order container that can be
# used with the methods verifyOrder and placeOrder.
virtual_guest = virtual_guest_service.createObject(virtual_guest_template)
puts JSON.pretty_generate(virtual_guest)
rescue StandardError => exception
puts "There was an error in your order: #{exception}"
end
I just tried to up a new VM managed by Puppet.
When upgrading some packages, the following messages pops up:
Setting up libssl1.0.0:amd64 (1.0.1e-2+deb7u12) ...
Checking for services that may need to be restarted...done.
Checking for services that may need to be restarted...done.
Checking init scripts...
[1;24r(B)0[m[1;24r
Package configuration┌─────────────────────┤
Configuring libssl1.0.0:amd64 ├─────────────────────┐│││
There are services installed on your system which need to be restarted ││
when certain libraries, such as libpam, libc, and libssl, are upgraded. ││
Since these restarts may cause interruptions of service for the system, ││
you will normally be prompted on each upgrade for the list of services ││
you wish to restart. You can choose this option to avoid being││ prompted;
instead, all necessary restarts will be done for you││
automatically so you can avoid being asked questions on each library││ upgrade.││││
Restart services during package upgrades without asking?││││
<Yes><No>│││└───────────────────────────────────────────────────────────────────────────┘
Failed to open terminal.debconf: whiptail output the above errors, giving up!
Setting up libgnutls26:amd64 (2.12.20-8+deb7u2) ...
dpkg: error processing libssl1.0.0:amd64 (--configure):
subprocess installed post-installation script returned error exit status 255
Setting up libkrb5support0:amd64 (1.10.1+dfsg-5+deb7u2) ...
Setting up libk5crypto3:amd64 (1.10.1+dfsg-5+deb7u2) ...
Setting up libkrb5-3:amd64 (1.10.1+dfsg-5+deb7u2) ...
Setting up libgssapi-krb5-2:amd64 (1.10.1+dfsg-5+deb7u2) ...
Setting up libmagic1:amd64 (5.11-2+deb7u5) ...
Setting up file (5.11-2+deb7u5) ...
Setting up libxml2:amd64 (2.8.0+dfsg1-7+wheezy1) ...
dpkg: dependency problems prevent configuration of libcurl3:amd64:
libcurl3:amd64 depends on libssl1.0.0 (>= 1.0.1); however:
Package libssl1.0.0:amd64 is not configured yet.
Then follow a bunch of failed package configurations leading my environment not to be as I wanted...
How can I make this work?
Thank you!
EDIT : Here's my node's manifest:
class pricing {
package { "libatlas-base-dev":
ensure => "installed" ,
require => Exec['apt-get update']
}
package { "gfortran":
ensure => "installed" ,
require => Exec['apt-get update']
}
class { 'python':
version => '2.7',
dev => true,
virtualenv => true,
pip => true,
}
class { 'postgresql::globals':
encoding => 'UTF8',
locale => 'en_GB.UTF-8',
manage_package_repo => true,
version => '9.3',
}->class { 'postgresql::client':
}->class { 'postgresql::lib::devel': }
package {"libffi-dev" : ensure => "present"}
package {"libxml2-dev" : ensure => "present"}
package {"libxslt-dev" : ensure => "present"}
if $pricing_state == "master" {
package {"rabbitmq-server" :
ensure => "present",
require => Exec['apt-get update'],
}
}
file { '/etc/boto.cfg':
source => 'puppet:///modules/pricing/boto.cfg',
}
file { "/pricing/logs/":
ensure => directory,
mode => 777,
owner => "celery",
group => "celery",
}
file { "/pricing/logs/pricing.logs":
ensure => file,
mode => 777,
owner => "celery",
group => "celery",
}
user { "celery":
ensure => present,
comment => "celery",
membership => minimum,
shell => "/bin/bash",
home => "/home/$name",
managehome => true,
}
exec { "import-gpg-dotdeb":
command => "/usr/bin/wget -q http://www.dotdeb.org/dotdeb.gpg -O -| /usr/bin/apt-key add -"
}
apt::source { 'dotdeb':
location => 'http://packages.dotdeb.org',
release => 'wheezy',
repos => 'all',
require => [Exec['import-gpg-dotdeb']]
}
class { 'redis':
package_ensure => 'latest',
conf_port => '6379',
conf_bind => '0.0.0.0',
system_sysctl => true,
conf_requirepass => '3I53G3944G9ngZC',
require => [Apt::Source['dotdeb']]
}
if $pricing_state == "master" {
if $env_small == "prod" {
include supervisord
supervisord::program { 'pricing':
ensure => present,
command => '/pricing/bin/python getprices.py',
user => 'root',
directory => '/pricing/',
numprocs => 1,
autorestart => 'true',
require => Python::Virtualenv['/pricing']
}
supervisord::program { 'listen_newprices':
ensure => absent,
command => '/pricing/bin/python listen_newprices.py',
user => 'root',
directory => '/pricing/',
numprocs => 1,
autorestart => 'true',
require => Python::Virtualenv['/pricing']
}
supervisord::program { 'getprixvente':
ensure => present,
command => '/pricing/bin/python getprixvente.py',
user => 'root',
directory => '/pricing/',
numprocs => 1,
autorestart => 'true',
require => Python::Virtualenv['/pricing']
}
supervisord::program { 'getprixachat':
ensure => present,
command => '/pricing/bin/python getprixachat.py',
user => 'root',
directory => '/pricing/',
numprocs => 1,
autorestart => 'true',
require => Python::Virtualenv['/pricing']
}
supervisord::program { 'flower':
ensure => present,
command => '/pricing/bin/celery flower --port=5555 --basic_auth=celery:celery69 --broker=amqp://celery:2xF09Ad050Ct7yb#127.0.0.1:5672//',
user => 'root',
directory => '/pricing/',
numprocs => 1,
autorestart => 'true',
require => Python::Virtualenv['/pricing']
}
exec { 'restart pricing':
command => 'supervisorctl restart pricing',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin/',
require => Supervisord::Program['pricing']
}
exec { 'restart getprixvente':
command => 'supervisorctl restart getprixvente',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin/',
require => Supervisord::Program['getprixvente']
}
exec { 'restart getprixachat':
command => 'supervisorctl restart getprixachat',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin/',
require => Supervisord::Program['getprixachat']
}
}
}
if $pricing_state == "slave" {
file { "/etc/init.d/celeryd":
ensure => file,
content => template('pricing/celeryd_init.erb'),
mode => 700,
owner => "root",
group => "root",
}
file { "/etc/default/celeryd":
ensure => file,
content => template('pricing/celeryd.erb'),
mode => 640,
owner => "root",
group => "root",
}
service { 'celeryd':
name => celeryd,
ensure => running,
enable => true,
subscribe => File['/etc/default/celeryd'],
require => [
File['/etc/default/celeryd'],
File['/etc/init.d/celeryd'],
User['celery'],
Python::Virtualenv['/pricing'],
],
}
exec { 'restart celeryd':
command => 'service celeryd restart',
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin/',
require => Service['celeryd'],
}
logrotate::rule { 'celerydslavelogs':
path => '/var/log/celery/*.log',
size => '100k',
rotate => 5,
}
}
logrotate::rule { 'celerydlogs':
path => '/pricing/logs/*.log',
size => '100k',
rotate => 5,
}
python::virtualenv { '/pricing':
ensure => present,
version => '2.7',
requirements => '/puppet/modules/pricing/files/requirements.txt',
owner => $user,
group => $user,
cwd => '/pricing',
timeout => 36000,
require => [
Class['postgresql::client', 'postgresql::lib::devel', 'python'],
Package['libatlas-base-dev', 'gfortran'],
Package['libffi-dev'],
Package['libxml2-dev'],
Package['libxslt-dev'],
Class['postgresql::client', 'postgresql::lib::devel', 'python'],
],
}
}
I've got a puppet manifest that resists my attempts to get it working right, given I'm no expert on the puppet DSL, and I'm fairly new to Puppet, I haven't managed to figure this out.
I'm trying to install Postgres using puppetlabs posgres module, creating a default role, and fixing up the DBs to work on UTF8.
Everything runs and installs, but the role doesn't get created. But if I run the provision again, then the role gets created. I assume perhaps has to do with the execution order, but honestly I'm lost.
Here's the code I'm using on my manifest file.
user { "user_vagrant":
ensure => "present",
}->
exec { 'apt_update':
command => 'apt-get update',
path => '/usr/bin/'
}
package { ['vim','postgresql-server-dev-9.1','libmysqlclient-dev','nodejs']:
ensure => 'installed',
before => Class['postgresql::server'],
require => Exec['apt_update'],
}
class { 'postgresql::server':
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => '*',
ipv4acls => ['local all all md5'],
postgres_password => 'postgres',
require => User['user_vagrant'],
}
postgresql::server::role { 'vagrant':
createdb => true,
login => true,
password_hash => postgresql_password("vagrant", "vagrant"),
require => Class['postgresql::server'],
} ->
exec { 'utf8_postgres':
command => 'pg_dropcluster --stop 9.1 main ; pg_createcluster --start --locale en_US.UTF-8 9.1 main',
unless => 'sudo -u postgres psql -t -c "\l" | grep template1 | grep -q UTF',
path => ['/bin', '/sbin', '/usr/bin', '/usr/sbin'],
}
Finally found the right approach to fix both the applied order, and the UTF8 issue which forced me to try the "pg_dropcluster" to begin with. Btw, this is a known issue here's the issue url http://projects.puppetlabs.com/issues/4695
This is the whole file I use to install PostgreSQL 9.1 with UTF8, and RVM ruby. Hope this helps.
Modules:
- puppetlabs/apt - 1.4
- puppetlabs/concat - 1.0
- puppetlabs/stdlib - 4.1.0
- puppetlabs/postgresql - 3.2
- blt04/puppet-rvm - git://github.com/blt04/puppet-rvm.git
stage { 'pre':
before => Stage['main']
}
class pre_req {
user { "vagrant":
ensure => "present",
}
exec { 'apt-update':
command => 'apt-get update',
path => '/usr/bin'
}->
exec { 'install_postgres':
command => "/bin/bash -c 'LC_ALL=en_US.UTF-8; /usr/bin/apt-get -y install postgresql'",
}
}
class { 'pre_req':
stage => pre
}
package { ['postgresql-server-dev-9.1']:
ensure => 'installed',
before => Class['postgresql::server']
}
class { 'postgresql::globals':
encoding => 'UTF8',
locale => 'en_US.UTF-8'
}->
class { 'postgresql::server':
stage => main,
locale => 'en_US.UTF-8',
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => '*',
ipv4acls => ['local all all md5'],
postgres_password => 'postgres',
require => User['vagrant']
}->
postgresql::server::role { 'vagrant':
createdb => true,
login => true,
password_hash => postgresql_password("vagrant", "vagrant"),
}
class rvm_install {
class { 'rvm': version => '1.23.10' }
rvm::system_user { vagrant: ; }
rvm_system_ruby {
"ruby-2.0.0-p247":
ensure => "present",
default_use => false;
}
rvm_gemset {
"ruby-2.0.0-p247#plyze":
ensure => present,
require => Rvm_system_ruby['ruby-2.0.0-p247'];
}
rvm_gem {
"puppet":
name => "puppet",
ruby_version => "ruby-2.0.0-p247",
ensure => latest,
require => Rvm_system_ruby["ruby-2.0.0-p247"];
}
rvm_gem {
"bundler":
name => "bundler",
ruby_version => "ruby-2.0.0-p247",
ensure => latest,
require => Rvm_system_ruby["ruby-2.0.0-p247"];
}
}
class { 'rvm_install':
require => User['vagrant'],
}