Can't run Ansible in daemon-mode - configuration-management

Can I run Ansible to manage my hosts like a daemon? For example, I sometimes change my playbooks and I don't want to run "ansible-playbook main.yml" manually. Please, don't propose crontab. There is a specific point and I can't use crontab on production server.
Thank you

What you are talking about here is called pull mode. Architectually Ansible is designed to work in push mode - you push changes to server from a control machine.
If you really would like to make Ansible work in pull mode then you can do so with Ansible-Pull script, see docs here: http://docs.ansible.com/playbooks_intro.html#ansible-pull
Ansible-pull is a script that can fetch your configuration playbooks from remote repository and run them against localhost. Ansible-pull does not however solve a problem of checking for a new configuration changes - you need to solve it yourself with cron.
Another alternative is using Ansible Tower (you need a paid license for it).
Ansible Tower supports callbacks via API, so the server you want to configure has to do API request to Ansible Tower server, Tower in turn will check whether the host that sent API request is in its inventory. If it's in inventory then Tower will start configuring it.

Related

Is it possible to host a Minecraft server on GitHub Codespaces?

I downloaded the Fabric server jar file to a GitHub Codespace and am able to run the server without trouble. However, I am unable to determine the IP needed to connect to the server. Starting the server automatically forwards port 25565 and I make the port public. However, I can't figure out which IP to paste into Minecraft to connect to it. How do I figure out the IP of the server?
I found an answer thanks to inspiration from this question.
Steps:
Set up the fabric server jar as you normally would, but on the codespace. Start the server.
Split the terminal so one is running Java (server console) and the other is running bash.
Install ngrok via npm i ngrok --save-dev.
Once the server is finished setting up, run the command ./node_modules/.bin/ngrok tcp 25565.
Copy the ip shown under Forwarding (minus the tcp:// part and including the port). This should look something like 4.tcp.ngrok.io:17063.
You now have the ip of the serve!
Note: The free version of ngrok has URLs which change every time, as well as a limit, but for small-scale servers this shouldn't be an issue. You are also limited by the free codespace usage limit GitHub puts in place. However, you can easily get around this by creating a secondary account that you use codespaces on only for the server.

Does Rundeck have to be online or I can simply host it on a local VM?

Does Rundeck have to be online or I can simply host it on a local VM? If it has to remain online, then why? or If it can be kept on a local VM would that work? if not, then why?
Rundeck needs to be online to execute the workflows that you define, whether in a virtual environment or not. Just make sure that the Rundeck instance can access the remote nodes.
A good way to test Rundeck is to use the official Docker image.

A way for client to trigger Ansible Playbook?

My task is to automate CentOS installs, including a suite of proprietary software, onto bare metal machines. I've set up a PXE boot server which automates initial install from a Kickstart file and the rest gets passed to an Ansible Playbook.
I've solved all of the above, except I have to be in the server to start the Playbook. I haven't found a good way for the Playbook to start at the request of the client (or perhaps the server-side PXE process can hand it off somehow?), in the hopes that I can cut myself out of the install process.
I thought I would expand on my comment a little bit.
Depending on what you're trying to accomplish, there are a few options you could consider.
Use ansible-pull
The ansible-pull cli fetches a git repository from a remote server and then locally executes ansible-playbook playbook.yml in the top level of that repository.
This means you can drop something like this into your Kickstart %post script:
ansible-pull -U https://server.example.com/playbooks/client-configuration
This is a great solution if your playbook only requires running tasks on the client.
Trigger a playbook run on the server
If your playbook really needs to execute on the server, you could set up a simple web server that would allow clients to trigger the playbook run. In this case, you would embed curl command or similar into your Kickstart %post script:
curl https://my.server.com/trigger-playbook
The trigger-playbook service would take care of triggering a playbook run targeting the appropriate client. This would require you to implement the service yourself (or use something like webhook to handle that task for you).

Is it possible to associate clients dynamically in sensu?

I'am using open source tools for the first time. I would like to install sensu, All i want to know that is there any method in which i can add my newly provisioned service automatically to the sensu server.
#vineesha We can make this possible when using rabbit mq, please write a script to fetch hostname and Ip address and update client.json and restart rabbitmq server and sensu-client. In the golden image please hard code the IP address of sensu server in rabbitmq.json. When all this is done please set a cron with #reboot and this should be all. When the server is launched it will automatically add to the sensu server.
If you are planning to use automation tools like for example puppet, all you need to do is to ensure that the sense-client is installed and the client config includes the correct RabbitMQ config.
As soon as the client connects to the same RabbitMQ host/cluster it should also pop up in you dashboard e.g. uchiwa.
There is no need to explicitly give the sense-server any information directly.

ssh site as parameter of jenkins job

I use jenkins to connect towards a ssh site and do some operation. This is possible through Publish Over SSH Plugin and it works well, but I have a lot of server and to use a ssh site I need to configure each one. I would like to use the ip of my machine as parameter in a jenkins job, without any configuration.
Is this possible?
Thanks in advance.
There is no problem whatsoever to put the IP address of your machine as, say, a string parameter for your build. You may put your machine's host name as well. I suppose though that I am missing something in your question.