I would like to know what is the utility of declaring environments in /etc/salt/master ?
Example :
file_roots:
base:
- /srv/salt
env1:
- /srv/salt/env1
This is the /srv/salt tree:
.
├── base
├── env1
│ └── domain1
│ ├── init.sls
│ └── nginx.conf
└── top.sls
And the top.sls:
env1:
'*':
- env1.domain1
This is the init.sls inside env1/domain1/
/etc/nginx/nginx.conf:
file.managed:
- source: salt://env1/domain1/nginx.conf
When executing:
salt '*' state.sls env1.domain1
everything works fine.
But with highstate:
# salt '*' state.highstate
myHost:
Data failed to compile:
----------
No matching sls found for 'env1.domain1' in env 'env1'
Given that the environment "env1" is declared in master config.I changed my configuration and I have put :
- source: salt://domain1/nginx.conf
instead of:
- source: salt://env1/domain1/nginx.conf
I had this error :
Comment: Source file salt://domain1/nginx.conf not found
Is there a misconfiguration somewhere ?
What is the utility of declaring environments in master conf,
if we can't call it directly using salt://subfolder instead of salt://environment/subfolder directly ?
I can't find a good documentation about creating environments and using them !
===Edit===
This is the new configuration:
The master:
file_roots:
base:
- /srv/salt/base
env1:
- /srv/salt/env1
The /srv/salt tree
.
├── base
│ └── init.sls
├── conf_template
├── env1
│ └── domain1
│ ├── init.sls
│ └── nginx.conf
└── top.sls
top.sls:
base:
'*':
- init
env1:
'*':
- domain1
And env1/domain1/init.sls:
/etc/nginx/nginx.conf:
file.managed:
- source: salt://domain1/nginx.conf
and the execution result:
salt '*' state.sls env1.domain1
myHost:
Data failed to compile:
----------
No matching sls found for 'env1.domain1' in env 'base'
No matching sls found for 'env1.domain1' in env 'env1'
I believe that's because the state reference should not include the environment, i.e. you have an extra env1, it should be:
env1:
'*':
- domain1
The other mistake you have is that you have env1 as a sub-directoy of base which can make things really confusing as this is not how environments are supposed to be structured.
Those are the only two mistakes I can spot and after fixing them, highstate should work as well as the reference to salt://domain1/nginx.conf (which is correct this way).
Finally, I believe environments are indeed confusing, and for me, I found I could better understand them by focusing on how they are actually implemented: multiple state trees. Technically, the concept of an "environment" doesn't exist. It's just one for us to utilize that feature.
Related
My config files structure:
config
├── train_dataset
│ ├── adobe5k.yaml
│ ├── my_train_data1.yaml
│ └── cifar10.yaml
├── valid_dataset
│ ├── adobe5k.yaml
│ └── cifar10.yaml
└── config.yaml
And my config.yaml is:
# other configs
...
defaults:
- train_dataset: adobe5k
- valid_dataset: adobe5k
As you see, I have 2 fields named valid_dataset and train_dataset in my config, whose value is selected from its own config group. What should I do to make values of the two fields selected from the same group?
You can use a config group more than once. Assume that you moved your dataset configurations into a single datasets directory. Then you can re-use them as follows.
- defaults:
- datasets#train_dataset: adobe5k
- datasets#valid_dataset: adobe5k
You can use Defaults List interpolation to achieve that. The Default List page high level information and you find a more practical example here for some details.
defaults:
- train_dataset: adobe5k
- valid_dataset: ${train_dataset}
This way, it will be enough for you to override train_dataset and the validation dataset would match it automatically (unless you override it too).
I have a typo3 extension (created with extension manager) and it seems no matter what I try I always get the following error:
Class CM\Parser\Controller\ParserController does not exist. Reflection failed.
I used the explanations for this problem TYPO3 tutorial extension, controller does not exist and "Controller does not exist. Reflection failed." TYPO3. Neither of them seem to work.
My composer.json in the root directory has the following entry:
"autoload": {
"psr-4": {
"CM\\parser\\": "./packages/cm-parser/Classes"
}
}
My typo3conf/ext folder has a symlink on packages/cm-parser. My composer.json inside the extension directory (packages/cm-parser) has the entry:
"autoload": {
"psr-4": {
"CM\\parser\\": "./Classes"
}
}
Thanks in advance for any help.
My directory structure looks like this (starting in /opt/lampp/htdocs/my-new-project) which is a typo3 v9.5 installation
> .
├── packages
│ └── cm-parser
│ ├── Classes
│ ├── Configuration
│ ├── Documentation.tmpl
│ ├── Resources
│ └── Tests
├── public
│ ├── fileadmin
│ │ ├── _processed_
│ │ ├── _temp_
│ │ └── user_upload
│ ├── typo3
│ │ └── sysext
│ ├── typo3conf
│ │ ├── ext
│ │ └── l10n
│ ├── typo3temp
│ │ ├── assets
│ │ └── var
│ └── uploads
│ └── tx_extensionbuilder
├── var
...
In my typo3conf/ext directory there is a symlink called parser to packages/cm-parser (I think the composer created that for me).
So I hope this symlink works for Typo3.
The files ext_emconf.php and ext_localconf.php are also in the right place. The folder structure above only displays my folders (tree -L 3) up to the third level.
The controller class is CM\Parser\Controller\ParserController, while in your composer.json you're using CM\\parser\\ (with a lowercase p) in the PSR4 autoload. This should be CM\\Parser\\
After changing this you need to of course run composer dumpautoload to reload the autoload information.
In your root composer.json file:
➊ You do not need the PSR-4 autoload section for "CM\\parser\\".
➋ You possibly have to add the path to packages/* as a repository.
➌ You have to include the composer namespace of your extension.
In your file system:
➍ You do not need typo3conf/ext/ as a symbolic link to packages/.
Try the following changes:
In your root composer.json file, remove the PSR-4 autoload section as outlined above. Add the packages/ directory as a path under repositories. For example:
{
"repositories": [
{
"type": "composer",
"url": "https://composer.typo3.org/"
},
{
"type": "path",
"url": "packages/*"
}
],
...
}
Store your extension code in the following path: packages/parser/.
Assuming your extension key reads parser and your vendor name is CM, the composer namespace becomes cm/parser. Add this as a requirement to the composer config file. You can use the following command on the command line:
composer require cm/parser:dev-master
This assumes, that packages/parser/ is a valid Git repository and has the master branch (do not use a version in the extension's composer.json file).
If the local Git repository and version (in the example above: dev-master) can be found, composer will automatically install all dependencies as required and it will create a symbolic link:
typo3conf/ext/parser -> ../../../packages/parser/
Also double check if all PHP files show the correct PHP namespace: CM\Parser\... and your controller class name reads ParserController.
If you can share your TYPO3 extension code, upload it to GitHub (or any other place) and share the link here. This way people can review your code and possibly spot further errors.
Here is the DockerFile.
FROM microsoft/aspnet:4.7
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
And here is the error.
Error
Building a.enterpriseextservices
Service 'a.enterpriseextservices' failed to build: COPY failed:
GetFileAttributesEx \\?\C:\Users\jesmiller-AM\AppData\Local\Temp\docker-
builder587295999\obj\Docker\publish: The system cannot find the file specified..
For more troubleshooting information, go to
http://aka.ms/DockerToolsTroubleshooting docker-compose C:\Program Files
(x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 349
I have published the project to the obj/Docker/publish folder.
Here is my docker-compose file. I used the docker-compose up command from the folder where the docker-compose.yml file is located.
version: '3'
services:
a.web.familyconnection:
image: a.web.familyconnection
build:
context: .\FamilyConnection
dockerfile: Dockerfile
b.enterpriseextservices:
image: b.enterpriseextservices
build:
context: .\Framework\b.EnterpriseExtServices
dockerfile: Dockerfile
I had the same issue. Turned out I made a silly mistake. I added the following to my .dockerignore file, just out of habit when setting up a new project:
bin
obj
.vs
.git
Then I tried running this in my Dockerfile
COPY ./bin/publish/ .
Docker gave the strange tmp path error, because it was falling back to that path since I told it to ignore my /bin folder. Once I copied to a different publish path (not bin), the problem went away.
It looks like your path to the folders, or where you've published your code at may be incorrect. The project should be published in the obj/Docker/publish folder inside of the respective folders defined by context
Using an example docker-compose.yml:
version: "3"
services:
foo:
build: ./foo
bar:
build: ./bar
And Dockerfile:
FROM jaydorsey/ruby-2.4.1
COPY ${source:-obj/Docker/publish} .
And a tree structure like this:
.
├── Dockerfile
├── bar
│ └── Dockerfile
├── docker-compose.yml
├── foo
│ └── Dockerfile
└── obj
└── Docker
└── publish
When I run docker-compose build I get the following error
Building foo
Step 1/2 : FROM jaydorsey/ruby-2.4.1
---> b79899b232f6
Step 2/2 : COPY ${source:-obj/Docker/publish} .
ERROR: Service 'foo' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder186649811/obj/Docker/publish: no such file or directory
This isn't identical to yours, since I'm running macOS, but very similar. You'll note the temporary file location (which is an internal Docker artifact of how it's copying files around) and the similarity in the docker-build<randomstring> path
However, if I create the obj/Docker/publish folders underneath each respective subfolder (context), the docker-compose build command works fine.
.
├── Dockerfile
├── bar
│ ├── Dockerfile
│ └── obj
│ └── Docker
│ └── publish
├── docker-compose.yml
├── foo
│ ├── Dockerfile
│ └── obj
│ └── Docker
│ └── publish
└── obj
└── Docker
└── publish
Please check that the folder you've published exists under the contexts as noted, and not in the root.
I still believe this is a path issue as noted in the error message. I hope this provides some context that helps you debug the root cause.
Can you please confirm your file & folder layout? I'm fairly certain it's path related because of the error message. I haven't done any Docker for Windows work either but I'd also double-check your default path using the correct slash (forward vs backward)
I really like eslint for es6 projects. Previously I've used it for new projects. Now I want to add it to a legacy project.
Fixing all pre-existing lint issues in one go is too much effort. Can I configure eslint (in .eslintrc.js) to only check files where I've explicitly enabled it with /* eslint-enable */ or similar?
ESLint has no default-disabled state that can be toggled by a file comment. You might be able to use .eslintignore for this purpose, however. You can ignore everything and then gradually whitelist files as you migrate them by using ! to un-ignore individual files. For example:
.
├── .eslintignore
├── .eslintrc.js
├── package.json
├── node_modules
│ └── ...
├── src
│ ├── index.js
│ └── module
│ └── foo.js
└── yarn.lock
Then your .eslintignore could look something like this:
# Start by ignoring everything by default
src/**/*.js
# Enable linting just for some files
!src/module/foo.js
In this case, src/index.js would be ignored, but it would lint src/module/foo.js.
I am using Sprockets with Sinatra, as suggested in Sinatra's page docs, but I can't make it work.
When I go to localhost:4567, the page loads correctly but with no styles. If I go to localhost:4567/assets/app.css, I get a not found error. I wonder what I am missing or what is wrong in the way I am using Sprockets?
This is my folder structure:
├── assets
│ ├── css
│ │ ├── app.css
│ │ ├── base.css
│ │ └── normalize.css
├── bin
│ └── app
├── lib
│ ├── app_assets.rb
│ └── main.rb
├── spec
│ ├── spec_helper.rb
│ └── main_spec.rb
├── views
│ └── index.erb
├── Gemfile
├── Gemfile.lock
├── Rakefile
├── .rspec
└── .ruby-version
The contents of app.css are:
//= require normalize
//= require base
The contents of app_assets.rb are:
module AppAssets
def self.environment root_path
environment = Sprockets::Environment.new root_path
environment.append_path './assets/css/'
environment
# get assets
get '/assets/*' do
env['PATH_INFO'].sub!('/assets', '')
settings.environment.call(env)
end
end
end
The contents of lib/main.rb are:
require 'sinatra'
require 'sprockets'
require 'app_assets'
class Main < Sinatra::Base
set :views, "#{settings.root}/../views"
get '/' do
erb :index
end
end
The file views/index.erb contains the line:
<link rel="stylesheet" href="assets/app.css">
And the contents of bin/app are:
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'sinatra'
require 'sprockets'
require 'app_assets'
require 'main'
Main.run!
Which I run typing:
$ bin/app
Any help would be appreciated, I'm sure I made something wrong but I can't see what. Can anybody spot it?
The app_assets.rb file is the problem here. When you require this file inside another file, the methods you define inside this module are not automatically included. You need to explicitly include AppAssets wherever you need the self.environment method to exist.
The second issue here is that self.environment is not equivalent to settings.environment. If I understand correctly, what you're trying to do is define the asset routing whenever the module gets included. To achieve this one way is to use the included hook for modules. This hook gets run every time you include a module inside a context. If you use that, the code in app_assets.rb turns to:
module AppAssets
def self.included(klass)
environment = Sprockets::Environment.new klass.settings.root
# note the change to path. Since the file where this gets included
# is inside a sub-folder, we need to traverse to one level above.
environment.append_path '../assets/css/'
klass.set :environment, environment
klass.get '/assets/*' do
env['PATH_INFO'].sub!('/assets', '')
klass.settings.environment.call(env)
end
end
end
The klass argument to this hook is the class into which this module is included. In our case this is the Sinatra class you've described in main.rb. That file looks like:
class Main < Sinatra::Base
include AppAssets
# Same as what you have
end
There's a Sinatra Recipes article about using Sprockets with Sinatra: http://recipes.sinatrarb.com/p/asset_management/sprockets?#article