Error to cloning project with puppet on vagrant - django

I am trying to install django and clone a github project with a puppet script. I am using modules as follows:
files
(empty directory)
manifests
nodes.pp
web.pp
modules
django
manifests
init.pp
files
(empty directory)
git
manifests
init.pp
files
(empty directory)
postgres
Within the web.pp file I have:
import ' nodes.pp '
In nodes.pp file I have:
node default {
include postgres
include git
include django
}
In init.pp file within the Manifests folder that is inside the git folder I have the following code:
class git{
include git::install
}
class git::install{
package { 'git:':
ensure => present
}
}
define git::clone ( $path, $dir){
exec { "clone-$name-$path":
command => "/usr/bin/git clone git#github.com:$name $path/$dir",
creates => "$path/$dir",
require => [Class["git"], File[$path]],
}
}
In init.pp file within the Manifests folder that is inside the django folder I have the following code:
class django{
include django::install, django::clone, django::environment
}
class django::install {
package { [ "python", "python-dev", "python-virtualenv", "python-pip",
"python-psycopg2", "python-imaging"]:
ensure => present,
}
}
class django::clone {
git::clone { 'My GitHub repository name':
path => '/home/vagrant/',
dir => 'django',
}
}
define django::virtualenv( $path ){
exec { "create-ve-$path":
command => "/usr/bin/virtualenv -q $name",
cwd => $path,
creates => "$path/$name",
require => [Class["django::install"]],
}
}
class django::environment {
django::virtualenv{ 've':
path => '/usr/local/app',
}
}
To run the scripts puppet I use the command:
sudo puppet apply --modulepath=/vagrant/modules /vagrant/manifests/web.pp
and run this command I get the following error:
Could not find dependency File[/home/vagrant/] for
Exec[clone-My GitHub repository name-/home/vagrant/] at
/vagrant/modules/git/manifests/init.pp:16
Note: where is the name 'My GitHub repository name', I put the name of my github repository correctly.
What is wrong and how do I solve this problem?

in your define git::clone have you made sure to declare the file resource for $path?
you should have:
file { $path: ensure => directory }
you can't require a resource that you haven't specifically delcared

Related

how to use --staging flag in substrate framework?

If i try to run the below command:
./target/release/node-template build-spec --chain staging > stagingSpec.json
facing the below error:
Error: Input("Error opening spec file: No such file or directory (os error 2)")
Is there any guide how to use that staging flag??
Here are the rustdocs for the command, and it's implementation in the node template - this looks for specific from your chain specification file based on what you pass that is configued. In the template at the time of writing, the template only has dev and "everything else" mode:
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()?),
"" | "local" => Box::new(chain_spec::local_testnet_config()?),
path =>
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
Thus you would need to specify another in/node/src/chainspec.rs and configure the /node/src/commnad.rs to use the correct one when called.

How to run Rails System tests in Heroku CI

How do I configure Heroku CI to run System tests?
This is my app.json, where I included what I thought would be the necessary buildpacks:
{
"environments": {
"test": {
"scripts": {
"test-setup": "bin/rails assets:precompile",
"test": "bin/rails test:system"
},
"addons":[
"heroku-postgresql:in-dyno"
],
"buildpacks": [
{ "url": "https://github.com/heroku/heroku-buildpack-google-chrome" },
{ "url": "heroku/nodejs" },
{ "url": "heroku/ruby"}
]
}
}
}
But when I deploy, I get the following error:
-----> Running test command `bin/rails test:system`...
rails aborted!
Webdrivers::BrowserNotFound: Failed to find Chrome binary.
I suspect I am missing something very basic....
I running Rails 6.0.1 and Ruby 2.6.3.
Did you setup your webdriver correctly to find the correct binary as mentioned on the official UAT wiki page of heroku?
Add gem 'webdrivers' to your Gemfile.
Add the following code snippet to your test_helper.rb (as stated on heroku buildback wiki and on webdrivers wiki):
require 'webdrivers' # Make sure webdrivers are loaded.
chrome_bin = ENV['GOOGLE_CHROME_SHIM'] if ENV['GOOGLE_CHROME_SHIM'].present?
chrome_capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: {
# You may want to use a different args
args: %w[headless disable-gpu window-size=1400x1400],
binary: chrome_bin
}
)
Capybara.register_driver :heroku_chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: chrome_capabilities)
end
Afterwards tell your system test to use your custom chrome driver by adding it to your application_system_test_case.rb.
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :heroku_chrome
end

Deploying to elastic beanstalk using gulp - Static files permissions issue

Recently I've had to change from using eb deploy to using a gulp task to deploy my project to AWS elastic beanstalk.
The reason for this is that I need to babel transform ES6 files to ES5. I don not want to commit the transformed files to our git and eb deploy uses the git-archive command to make the zip to deploy.
The transform and deploy works, I'm running into an issue with static files.
gulp.task('ebDeploy', function() {
return gulp.src([
'./.ebextensions/**', // Include the .ebextensions folder
'./**/*.js', // Match all .js files
'!./es6/**/*', // Exclude files in /es6 dir
'!node_modules', '!node_modules/**', // Exclude the node_modules folder and contained files
'*.js', // Include JS Files in the base dir
'package.json', // Include this specific file in base dir
'./config/**', // Include everything under /config
'./public/**', './public/**/*', // Include everything under /public
'./views/**/*.ejs' // Include all .ejs files under /views
], { base: './' })
.pipe(print())
.pipe(gulpEbDeploy({
//name: 'my-application', // optional: If not set, the name from package.json will be used
//version: '1.0.0', // optional: If not set, the version from package.json will be used
timestamp: true, // optional: If set to false, the zip will not have a timestamp
waitForDeploy: true, // optional: if set to false the task will end as soon as it starts deploying
amazon: {
// accessKeyId: "< your access key (fyi, the 'short' one) >", // optional
// secretAccessKey: "< your secret access key (fyi, the 'long' one) >", // optional
// signatureVersion: "v4", // optional
region: 'eu-west-2',
bucket: 'elasticbeanstalk',
applicationName: 'foo',
environmentName: 'bar'
}
}))
});
I have checked the zip that get's uploaded and it contains all the correct files. However it seems that eb deploy does something to permissions that i need to duplicate.
When I use eb deploy (after committing the /build files which I'm trying to prevent)
Everything works fine.
When I use my gulp task: I get the following error when trying to access static files.
06:49:28.81 server.js:98 | Global Error Handler
06:49:28.81 server.js:99 | { Error: EACCES: permission denied, stat '/var/app/current/public/css/default.css'
at Error (native)
errno: -13,
code: 'EACCES',
syscall: 'stat',
path: '/var/app/current/public/css/default.css',
expose: false,
statusCode: 500,
status: 500 }
What do I need to do to make these files work as intended.

Curl Exec lein with Puppet on Centos Vagrant no such file or directory

EDIT
This sites.pp seems to work.
class lein {
$lein = "/usr/local/bin/lein"
$url = 'https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
exec { 'download lein':
command => "/usr/bin/curl -sL -o ${lein} ${url}",
creates => $lein,
}
file { $lein:
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
command => $lein,
require => File[$lein],
}
}
I'm trying to install lein on a Centos Vagrant using Puppet.
To install lein you just run the script. I'm trying to dowload the script with curl, make it executable and then executing it but I'm getting no such file or directory. I have verified that the file /usr/local/bin/lein exists, so not sure why I'm getting the error.
So what I'm trying to accomplish is the puppet equivalent of this shell:
curl -sL -o /usr/local/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
chmod 0755 /usr/bin/local/lein
/usr/local/bin/lein
Also on a side note, is it possible to run exec as a non-privileged user?
puppet/manifests/site.pp
class lein {
exec { 'download lein':
command => 'curl -sL -o /usr/local/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein',
path => '/usr/bin',
}
file { '/usr/local/bin/lein':
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
command => 'lein',
path => '/usr/local/bin',
require => File['/usr/local/bin/lein'],
}
}
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "puphpet/centos65-x64"
config.vm.provision "puppet" do |p|
p.module_path = "puppet/modules"
p.manifests_path = "puppet/manifests"
p.manifest_file = "site.pp"
end
end
Also on a side note, is it possible to run exec as a non-privileged user?
Yes, you can, add the user in your block
class lein {
$lein = "/usr/local/bin/lein"
$url = 'https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
exec { 'download lein':
command => "/usr/bin/curl -sL -o ${lein} ${url}",
creates => $lein,
user => "vagrant";
}
file { $lein:
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
command => $lein,
require => File[$lein],
user => "vagrant";
}
}
include lein
On a much simpler note: have you tried piping?
class lein {
$command = 'curl -sL https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein | bash -s install'
package { 'curl':
ensure => 'installed',
}
exec { 'download lein':
command => $command,
path => $::path,
require => Package['curl'],
}
}
I got it to work by removing the path to both execs and using absolute paths for the commands. Also lein needs the HOME environment set or else it will try and download files to /.lein and it needs to be ran as vagrant
Successful sites.pp
class { 'jdk_oracle': }class lein {
$lein = "/usr/local/bin/lein"
$url = 'https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein'
$leinhome = '/home/vagrant'
exec { 'download lein':
command => "/usr/bin/curl -sL -o ${lein} ${url}",
creates => $lein,
require => Class['jdk_oracle']
}
file { $lein:
mode => '0755',
require => Exec['download lein'],
}
exec { 'install lein':
environment => ["HOME=${leinhome}"],
command => $lein,
require => File[$lein],
creates => "${leinhome}/.lein/self-installs/leiningen-2.5.3-standalone.jar",
user => 'vagrant',
}
}
include jdk_oracle
include lein

Configuring Blackfire on a base virtual box using Chef

I'm trying to give Blackfire.io (by Sensiolabs) a try to profile an existing PHP application running on a Vagrant machine (with PHP 5.3) on Mac.
I'm using Chef to provision my machine with Blackfire, but when running "vagrant provision" I get the following error:
default: STDERR: The server ID parameter is not set. Please run
blackfire-agent -register to configure it.
..which I already did
This is my Vagrant file:
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
Vagrant.configure("2") do |config|
..
config.vm.box = "covex/ubuntu1204-x64"
config.omnibus.chef_version = :latest
config.vm.provision "chef_solo" do |chef|
chef.json = {
:blackfire => {
:'server-id' => "d4860b49-be67-404b-9fa1-b..",
:'server-token' => "c412751f30d6c724033d8408e.."
}
}
chef.add_recipe "blackfire"
end
end
I followed the installation steps on https://blackfire.io/getting-started, except for the Probe paragraph.
Is my Vagrant file wrongly configured, so it can't read the server ID and token? Is the "brew install blackfire-php53" needed for this, if so, is there a way to configure this through my Vagrant file?
Guessing you are using https://supermarket.chef.io/cookbooks/blackfire
You missed the agent node in the config tree
{
"blackfire" => {
"agent" => {
"server-id" => "your server-id",
"server-token" => "your server-token",
}
}
}