Foreman v1.7 Environment blank/null - puppet

Issue:
In Foreman I see the Environment column empty for this (and any other client) I try to add.
Environment:
I have a Foreman 1.7 Server with 2 additional Puppet masters (3.8.2) which are seen in Smart-Proxies and look healthy. I have created a new environment call 'destruct' which is defined in /etc/puppet/environments on all 3 servers with 'puppet' as the owner.
/etc/puppet/environments/destruct/
├── manifests
└── modules
└── linux_ntp
├── manifests
│   ├── config.pp
│   ├── init.pp
│   ├── install.pp
│   ├── params.pp
│   └── service.pp
├── metadata.json
├── Modulefile
├── Rakefile
├── README.markdown
├── spec
│   ├── spec_helper.rb
│   └── spec.opts
├── templates
│   └── ntp.conf.erb
└── tests
└── init.pp
The environments path is specified in the [master] section in puppet.conf in all 3 servers (foreman server + 2 external puppet masters) so directory environments should be in play.
environmentpath = /etc/puppet/environments
basemodulepath = /etc/puppet/modules
I added the 'destruct' environment in Foreman: Configure->Environments, after which I ran the import from all 3 servers and it did not try to remove it, and it did import that single ntp module.
When I attempt to add a new puppet agent I specify the environment as 'destruct' in puppet.conf:
report = true
pluginsync = true
masterport = 8140
certname = clientname.domain
server = puppetserver1.domain
listen = true
environment = destruct
ca_server = foremanserver1.domain
However in Foreman I see the Environment column empty for this (and any other client) I try to add. There are no errors on the puppet agent indicating it cannot find that environment.
I am able to manually assign a sever to an environment after it is in Foreman and successfully run modules, but that is far from ideal.
Any ideas why client systems are not being automatically assigned to the correct environment?

It appears that this behavior is expected. If you are using Foreman only as a puppet ENC then when a new sever is added via the puppet agent it does not auto-populate the Puppet Environment in Foreman based on what is in puppet.conf 'environment' variable, as I expected.
It looks like the best way is to create the Hosts in Foreman (via the API or WebUI) then your puppet environment in Foreman would be correctly applied.

Related

VS Code - Golang "go module packages.Load error"

Backstory
I got this error amongst numerous others setting up a new virtual box LMDE5 on my new windows 11 pro computer. I haven't used windows in about 12 years, and the changes were crazy causing countless errors on Windows and LMDE5 Vbox.
My last issue was this in vs code.
Error
go module packages.Load error: err: exit status 2: stderr: go: no such tool "compile": go list
My project directory structure
.
├── docker-compose.yaml
├── project.code-workspace
├── go.mod
├── go.sum
├── main.go
└── sub_packages
├── backend
│ ├── folder1
│ ├── folder2
├── api
│ ├── handlers
│ └── requests
├── entities
├── services
└── utils
settings.json file
{
// ...
"go.goroot": "/usr/local/go",
"go.gopath": "/home/user_name/go",
// ...
}
Solution
Add the go tool dir ENV variable directly to VS Code settings.json to the settings to pickup the location of the folder .../linux_amd64 where compile was located.
settings.json file
{
// ...
"go.goroot": "/usr/local/go",
"go.gopath": "/home/username/go",
"go.alternateTools": {
"GOTOOLDIR": "/usr/local/go/pkg/tool/linux_amd64"
},
// ...
}

Source Terraform Module From Sub-Directories In a BitBucket Repository With A different branch

I have a terraform modules repository with different set of modules with below structure
BitBucket Repository(URL: git#bitbucket.org:/{repoName}.git?ref=develop
└── modules
├── s3
│   ├── locals.tf
│   ├── main.tf
│   ├── output.tf
│   └── variables.tf
└── tfstate
└── main.tf
develop is the branch that I want to use which I have given in the source URL. I am calling the module repository as given below:
├── examples
│   ├── gce-nextgen-dev.tfvars
│   └── main.tf
main.tf
module "name" {
source = "git#bitbucket.org:{url}/terraform-modules.git? ref=develop/"
bucketName = "terraformbucket"
environment = "dev"
tags = map("ExtraTag", "ExtraTagValue")
}
How can I call the modules from sub-directories which is in a BitBucket repository.
It works if I remove the ref=develop from the URL and just give git#bitbucket.org:{url}/terraform-modules.git//modules//s3
But I don't want to use master but develop branch in this case.

express js In which folder does a controller.js belong

You can create controller for each route file to better manage your code. The routes have it's own folder in the root directory of a express project but where does the controllers belong?
I have seen that they have an own folder named "controllers" in the root directory too but I have also seen that each router has his own folder where router.js and index.js (the controller) are.
But what is the right folder structure for controllers for express js projects?
Ohk, just don't get too much confused. Organizing the files and folders totally depends on you, Express or node doesn't force you to maintain specific structure. In general developers like to keep things like below:
.
├── config # App configuration files
│ ├── sequalize.json # Sequalize config
│ ├── serviceOne.json # ServiceOne config
│ └── ... # Other configurations
├── routes
│ ├── controllers # Request managers
│ ├── middlewares # Request middlewares
│ └── routes.js # Define routes and middlewares here
├── services # External services implementation
│ ├── serviceOne
│ └── serviceTwo
│ └── ... # Other services
├── db # Data access stuff (Sequalize mostly)
│ ├── models # Models
│ ├── migrations # Migrations
│ ├── seeds # Seeds
│ └── index.js # Sequalize instantiation
├── core # Business logic implementation
│ ├── accounts.js
│ ├── sales.js
│ ├── comments.js
│ └── ... # Other business logic implementations
├── utils # Util libs (formats, validation, etc)
├── tests # Testing
├── scripts # Standalone scripts for dev uses
├── pm2.js # pm2 init
├── shipitfile.js # deployment automation file
├── package.json
├── README.md
└── app.js # App starting point
For more details you can refer https://medium.com/codebase/structure-of-a-nodejs-api-project-cdecb46ef3f8
If you have an exigence to implement your server-side project with Express js follow the answer below , or I suggest for you Nest.js
Nest (NestJS) is a framework for building efficient, scalable Node.js™ server-side applications
It has his own structure (services, controllers, routers ) well organized, and implementing good practices for server-side projects, take a look
It all depends on what you want, express don't have a "you need to use this format or else your api will surely fail" rule.
If you have an experience with using a PHP framework before, you can follow their MVC project structure if you want to or you can follow this nodejs best practices.

puppet not recognizing supported modules

When I try to install basic Windows modules (new to puppet) they are not recognized when I try to add their classes to a new group.
When I list the modules I can see them, when I checked the production module path it is in the right place, why can't I see them in the GUI?
Thanks..
[root#puppetmaster ~]# puppet module list <br>
/etc/puppetlabs/code/environments/production/modules<br>
├── badgerious-windows_env (v2.2.2)<br>
├── chocolatey-chocolatey (v1.2.1)<br>
├── puppet-download_file (v1.2.1)<br>
├── puppet-iis (v1.4.1)<br>
├── puppet-windowsfeature (v1.1.0)<br>
├── puppetlabs-acl (v1.1.2)<br>
├── puppetlabs-apache (v1.8.0)<br>
├── puppetlabs-concat (v1.2.5)<br>
├── puppetlabs-powershell (v1.0.6)<br>
├── puppetlabs-reboot (v1.2.1)<br>
├── puppetlabs-registry (v1.1.3)<br>
├── puppetlabs-stdlib (v4.11.0)<br>
├── puppetlabs-windows (v2.1.1)<br>
└── puppetlabs-wsus_client (v1.0.1)<br>
/opt/puppetlabs/puppet/modules<br>
├── puppetlabs-pe_accounts (v2.0.2-6-gd2f698c)<br>
├── puppetlabs-pe_concat (v1.1.2-7-g77ec55b)<br>
├── puppetlabs-pe_console_prune (v0.1.1-9-gfc256c0)<br>
├── puppetlabs-pe_hocon (v2015.3.0-rc0)<br>
├── puppetlabs-pe_inifile (v1.1.4-16-gcb39966)<br>
├── puppetlabs-pe_java_ks (v1.2.4-37-g2d86015)<br>
├── puppetlabs-pe_nginx (v2015.2.0-rc0)<br>
├── puppetlabs-pe_postgresql (v3.4.4-35-g51cdb78)<br>
├── puppetlabs-pe_puppet_authorization (v2015.3.0-rc1-31-g6d266e1)<br>
├── puppetlabs-pe_puppetdbquery (v2015.3.0-rc1-1-gb278efd)<br>
├── puppetlabs-pe_r10k (v2015.2.2-2-g21c67b9)<br>
├── puppetlabs-pe_razor (v0.2.1-84-gbb045d2)<br>
├── puppetlabs-pe_repo (v2015.3.0-rc2-39-g796afc6)<br>
├── puppetlabs-pe_staging (v0.3.3-24-g2d5dbb0)<br>
└── puppetlabs-puppet_enterprise (v2015.3.1-1-g8c41b9f)<br>
[root#puppetmaster ~]# puppet config print modulepath --section master --environment production
/etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules
In order to make the foreman GUI fetch installed modules, You need a foreman-proxy running with puppet.yml file enabled in it.
Note: I hope you have a working foreman-proxy running with puppet.yml
file enabled. If it's not running, please enable puppet in
foreman-proxy and configure proxy settings in foreman GUI. That's
enough to make the classes visible.
I also pasted my puppet.conf file, just incase if you need.
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
environment=production
reports=log, foreman
[master]
dns_alt_names = yourdomain.com
certname=yourdomain.com
external_nodes=/etc/puppet/node.rb
node_terminus=exec
[agent]
server=yourdomain.com
listen=true
[production]
modulepath=/etc/puppetlabs/code/environments/production/modules

Change Yesod port number

From Deploying Yesod web app, I could copy the executable, static, and config file to run Yesod as a standalone web server. This is the directory structure.
├── config
│   ├── client_session_key.aes
│   ├── favicon.ico
│   ├── keter.yml
│   ├── models
│   ├── robots.txt
│   ├── routes
│   ├── settings.yml
│   ├── sqlite.yml
│   └── test-settings.yml
├── my-project
├── my-project.sqlite3
└── static
I tried to use different port by changing config/settings.yml
port: "_env:PORT:3002"
approot: "_env:APPROOT:http://localhost:3002"
However, the app is still accessible with port 3000. Even I removed the settings.yml, but there was no error message.
The way to change the port was from changing the environment variables export PORT=3002 from https://github.com/yesodweb/yesod/wiki/Configuration#overriding-configuration-values-with-environment-variables, but I it's not what I can use.
For development I can use stack exec -- yesod devel -p 3003 (how can I change the settings (e.g., port) used by "yesod devel"?), but I don't seem to use the -p option with the Yesod executable (my-project).
Why the executable does not (seem to) load config/settings? How to setup to use different port in Yesod web app?
It looks like that the setting file should be in the same directory as the executable.
I copied config/settings.yml in current directory, then run the ./my_project settings.yml, now it uses the 3002 port correctly.
I have some hints from https://github.com/yesodweb/yesod/issues/474

Resources