Can a Chef Server have multiple workstations? - continuous-integration

We have a predefined configuration of the infrastructure where the nodes have a particular runlist of recipes controlled using a central Chef server and workstation.
I want to implement a knife command to force a deploy recipe to be run on all the nodes. Is it possible just to run the knife -o recipe command from a new workstation and let the server sync all the recipes from the central workstation itself?

Yes, you can use multiple workstations, but not quite the way you describe. When you push a cookbook (or policy) it gets uploaded into the Chef Server. All client nodes only talk to your Chef Server, not the workstation. That includes cookbooks and run lists (unless overridden with -o as you noted). So you can run knife ssh somequery sudo chef-client from any workstation any have it function the same.

Related

How to configure docker swarm using jenkins?

I have got an assignment. The assignment is "Write a shell script to install and configure docker swarm(one master/leader and one node) and automate the process using Jenkins." I am new to this technology and finding it difficult to proceed. Can anyone help me in explaining step-by-step process of how to proceed?
#Rajnish Kumar Singh, Have you tried to check resources online? I understand you are very new to this technology, but googling some key words like
what is docker swarm
what is jenkins , etc would definitely helps
Having said that, Basically you need to do below set of steps to complete your assignment
Pre-requisites
2 or more - Ubuntu 20.04 Server
(You can use any linux distros like ubuntu, Redhat etc, But make sure your install and execute commands change accordingly.
Here we need two nodes mainly to configure the master and worker node cluster)
Eg :
manager --- 132.92.41.4
worker --- 132.92.41.5
You can create these nodes in any of public cloud providers like AWS EC2 instances or GCP VMs etc
Next, You need to do below set of steps
Configure Hosts
Install Docker-ce
Docker Swarm Initialization
You can refer this article for more info https://www.howtoforge.com/tutorial/ubuntu-docker-swarm-cluster/
This completes first part of your assignment.
Next, You can create one small shell script and include all those install and configuration commands in that script. Basically shell script is collection of set of linux commands. Instead of running each commands separately , you will run script alone and all set up will be done for you.
You can create small script using touch command
touch docker-swarm-install.sh
Specify proper privileges to script to make it executable
chmod +x docker-swarm-install.sh
Next include all your install + configure commands, which you have used earlier to do docker swarm set up in scripts (You can refer above shared link)
Now, when your script is ready, you can configure this script in jenkins job and whenever jenkins job is run, script will get execute and docker swarm cluster will be created
You need a jenkins server. Jenkins is open source software, you can install it in any of public cloud instance (Aws EC2)
Reference : https://devopsarticle.com/how-to-install-jenkins-on-aws-ec2-ubuntu-20-04/
Next once installation is completed. You need to configure job in jenkins
Reference : https://www.toolsqa.com/jenkins/jenkins-build-jobs/
Add your 'docker-swarm-install.sh' as build step in created job
Reference : https://faun.pub/jenkins-jobs-hands-on-for-the-different-use-cases-devops-b153efb483c7
If all set up is successful and now when you run your jenkins job, your docker swarm cluster must be get created.

Unable to bootstrap node on windows node using chef and knife

I've exhausted my options in trying to bootstrap a windows node running in azure. I have the workstation connected to my self-hosted chef server without any issues. I run the bootstrap command and get the following:
Creating new client for vm1
Creating new node for vm1
Connecting to 104.***.***.***
ERROR: Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout
I know the username and password are valid as well as the IP of the target node. What are my options here for debugging such a problem? I believe the necessary ports are open, unless I'm missing something special. I have telnet enabled. Does anyone have any better ideas?
To copy down from the comments, to bootstrap over WinRM you need the knife bootstrap windows winrm command.
you can also bootstrap windows machine with following command. Core Chef now supports bootstrapping Windows systems without a knife plugin
sudo knife bootstrap -o winrm <pubic_IPV4_Address/DNS_of_client_machine> -U Administrator -P '<pwd>' --node-name <node_name> --run-list 'recipe[<cookbook_name>]'
where,
pubic_IPV4_IP/DNS_of_client_machine --> Public IP address/ DNS of the client machine.
node_name --> String representing node name.
cookbook_name --> Cookbook that we want to execute on client machine.
pwd --> password to connect with windows client machine
Note: Make sure to execute above command from ~/chef-repo/.chef/ directory.
If you are unable to execute above command with -o winrm option then install below gem packages
chef gem install winrm
chef gem install knife-windows

Opscode Chef Server / Workstation force commands from server

Background : Chef Server Version 12 and a Windows workstation SDK 0.10 targeting windows nodes
I've created recipes and bootstrapped local windows servers into the Chef manager and applied recipes so the very basics are all working.
Question : when running the bootstrap commands for a hosted server (e.g azure / aws) I need the command to come from the Chef Server not the workstation.
I had hoped that the knife.rb with the Chef_server_url would force all commands to come from there.
WireShark shows the WinRM connections trying to come from my workstation.
Is there any setting I can implement that forces this in the knife.rb or elsewhere?
I had tried to add the following from searches but they've not been successful :
chef_zero.enabled false
local_mode false
Is this resolved through Chef Provisioning rather than Chef knife commands?
many thanks in advance for any assistance you can give.
"when running the bootstrap commands for a hosted server (e.g azure / aws) I need the command to come from the Chef Server not the workstation." is not correct. Knife commands that manipulate servers go directly from your workstation, and this is how it is supposed to work. The way the bootstrap functions is it starts the cloud machine using the relevant provider API, then connects to the new VM via SSH or WinRM and installs Chef, and then launches chef-client using a configuration file based on your knife settings (this is where chef_server_url comes in).

CentOS 6.4 Minimal + how to configure jenkins jobs via xml?

I need to create a Build Server in CentOS 6.4 Minimal I sucessfully installed:
Java compiler (OpenJDK 1.7.0)
Git or Mercurial
Maven
Jenkins
Now I need to to the following:
At given intervals (eg daily at midnight) is the latest revision in the version control system (tip, HEAD, ...) compiled with Maven. In addition, Java Docs and packages (jar, war) need to be created.
Then Jenkins with all tests conducted and reported.
Make sure there is a report of previous builds
Ensure that the Java Docs and packages can be downloaded (jars, wars, ...) of the latest build
I can't use a GUI on CentOS Minimal so I need to configure the job in xml files? Could please someone show me the way... I'm not a linux server guru.
It's a bit impractical to configure Jenkins via XML by hand, because Jenkins' configuration is spread over multiple files, and the format of the configuration files changes between releases.
Given that Jenkins is a web application, you should be able to visit port 8080 (Jenkins' default port, assuming you didn't change it) on the server where you installed Jenkins (e.g. http://mycentosserver.example.com:8080), and configure it via the web interface.
If you're unable to access the web interface because of a firewall or similar, but you are able to SSH to the server (presumably you can, given that you were able to install stuff on it), you could set up an SSH tunnel to forward a port on your local machine to port 8080 on the server. For example, from your local machine, run the following command. You will then be able to access Jenkins on your local machine at http://localhost:28080 . If you're on Windows, you can use Putty to do the same thing.
ssh -L 28080:127.0.0.1:8080 mycentosserver.example.com
If you can't access the web app directly, and you can't SSH tunnel, I'd recommend setting up Jenkins on a server where you can access the web app, configuring it, and copying the XML config files from /var/lib/jenkins on that server across to your Centos server.

Running Chef cookbooks on ExaData

I am trying to run a Chef Cookbook on an ExaData server and I'm running into issues. I was able to bootstrap my ExaData servers. However when I run chef-client on the target nodes, I get an error like this. Then I went back and did a verbose output of the error, and still don't have any idea of what the issue is. I am able to ping, traceroute, and nc to and from the ExaData server to the Chef Server. None of the files transfer from the cookbook, or none of the files download from the remote Zabbix repository. The Chef run completes the role, and recipes but nothing is installed. Is there something different about ExaData from regular RHEL distributions that would cause issues?
--EDIT - 2013-07-15--
From looking at a "successful" chef-client run on a regular RHEL 6.2 OS, where as ExaData runs RHEL 5.8, I saw fewer errors. There does seem to be a lot of libraries missing from ExaData in order to run chef-client. From what I have heard, and read in other posts, was that ExaData is a stripped version of RHEL 5.8, using only what is needed to run databases.
According to a comment on the Chef IRC Logs the 404 message is because the client is attempting to use a feature that your server version doesn't support.
If you add the setting enable_reporting false to your client.rb file it should disable the request to the /reports URL.

Resources