Rundeck Manual Node Order - rundeck

I am using Rundeck to handle some server reboot operations to apply updates when needed and to refresh some servers that need to be rebooted on a regular basis. I am using Ansible on the backend to handle the inventory via a dynamic inventory plugin (Ansible queries Netbox for this). The function of this seems to be going smoothly aside from the fact that I cannot seem to figure out how to specify a manual node order for the nodes inside of a single job. I know that the Rank Attribute is supposed to be a means to accomplish this, but the documentation of how to use this and any examples doesn't really seem to exists.
Can I get more details on how I can go about specifying a manual order to the hosts within a job? As a stop-gap in the meantime, I have created one job per node and I only set one of the jobs to have a schedule and the other jobs get called one at a time in sequential order as a workflow step to accomplish me being able to control the node order, but this seems absurd to have to handle it this way via separate jobs. If I can make this work with the Rank Attribute feature or some other means, and in light of a dynamic inventory built from Netbox / Ansible, that would help me better simplify this and not have to create a job per node to accomplish this.
Thanks.

To use the "Rank Attribute" option in your job definition, you need to define an attributte in your node sources and pass it to the Rank Attribute textbox, for example, using this resources.xml (check myorder custom attribute):
<?xml version="1.0" encoding="UTF-8"?>
<project>
<node name="node00" description="Node 00" tags="" myorder="02" hostname="192.168.33.20" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck"/>
<node name="node01" description="Node 01" tags="" myorder="03" hostname="192.168.33.21" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck"/>
<node name="node02" description="Node 02" tags="" myorder="01" hostname="192.168.33.22" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck"/>
</project>
Then set "Rank Attribute" textbox with the myorder attribute, save the job and run again. You can see your job running in the order based on that attribute (or any other).
So, Rundeck needs the nodes at Model Source to achieve this, a good idea is to use the ansible model source to get the nodes at the Rundeck "nodes" section and use any attribute or just create a special one using Node Enhancer, take look at this.
More information here.
Based in this answer (check the update, probably it helps you).

Related

How to cleanup database in kubernetes after service is deleted?

Consider the following things are already satisfied.
1. The maria-db is running in separate pod and is pre-installed.
2. When we deploy a new service it is able to connect to maria-db and create SCHEMA in it.
But the final requirement is when the service is deleted then it should cleanup the SCHEMA.
I have tried writing a job with post-delete tag.
So just a thought, you could possible do this by using a Admission Control i.e your logic could possible be along the lines of:
Delete Pod Requested --> Hits Addmission Control --> Addmission Controller Removes Schema --> Pod Deleted
However this would be a lot of custom code and you would need a way to identify the Schema that that particular service has created in the DB.

One or more placement constraints on the service are undefined on all nodes that are currently up

trying to setup that specific services get deploy to specific node types I am getting this error using Visual Studio publish dialog (that breaks calling new-servicefabricapplication PS command)
I am using the service manifest to define the placementConstraints like this:
<StatelessServiceType ServiceTypeName="VisualObjects2.WebServiceType" >
<PlacementConstraints>(nodeType==node2)</PlacementConstraints>
</StatelessServiceType>
How can i define this placement constraints on the nodes?
In the Azure portal, go to your SF Cluster, select node types and for each one you can add a key-value list of placement constraints. There I put the key-value: nodetype = node2. After this, the deployment was done only in the nodes with this attribute

Why isn't it possible to change placement constraints in an upgrade?

I have a stateless ASP.NET Core (RC1) service running in my Azure Service Fabric cluster. It has the following manifest:
<ServiceManifest Name="MyServicePkg" Version="1.0.2" ...>
<ServiceTypes>
<StatelessServiceType ServiceTypeName="MyServiceType" />
</ServiceTypes>
...
</ServiceManifest>
My cluster is configured with placement properties. I have 5 servers with "nodeType=Backend" and 3 servers with "nodeType=Frontend".
I would like to upgrade my Service and specify that it may only be placed on "Backend" nodes. This is my updated manifest:
<ServiceManifest Name="MyServicePkg" Version="1.0.3" ...>
<ServiceTypes>
<StatelessServiceType ServiceTypeName="MyServiceType">
<PlacementConstraints>(nodeType==Backend)</PlacementConstraints>
</StatelessServiceType>
</ServiceTypes>
...
</ServiceManifest>
However, if I now execute the upgrade, I get the following error:
Start-ServiceFabricApplicationUpgrade : Default service descriptions
must not be modified as part of upgrade. Modified default service:
fabric:/MyApp/MyService
Why isn't it possible to change the constraints with an upgrade?
Would I have to delete and re-create the service? This would seem extremely problematic to me because it would result in downtime and data loss for stateful services.
So the issue here is actually with the DefaultService part of the ApplicationManifest. When services are created as part of the DefaultService, there are things you can't change about it afterwards. You might be able to change it through the ServiceFabric explorer, but I'm not sure.
One recommendation would be to keep the DefaultServices empty in the ApplicationManifest, and instead create your services manually. With manual I mean either through powershell, code or the ServiceFabric Explorer.
That gives you more flexibility about changing parts of the service afterwards. When it's done that way, you I know you have the possibility to change things like placement constraints after the service is running.
To create Services with PowerShell you can use the New-ServiceFabricService command.
To create it from code, you can use FabricClient to do it. A sample of that can be found here: Azure Service Fabric Multi-Tenancy
There's actually a fairly easy way to do this without having to write a bunch of code to manually define the application on the fabric cluster.
While you can declare the placement constraints in the service manifest, you can also declare them in the application manifest. Anything declared in the application manifest will override what's in the service manifest. And with the setting in the application manifest, you can then use parameters to alter the values based on the parameter file you want to a specific deployment.
I've just written up a blog post that discusses this approach in greater detail. I hope you find it useful. :)

Spring Data Mongodb - single configuration for standalone mongo and replicaset

I started out with a single mongo instance as my database, configured in spring xml:
<mongo:mongo host="localhost" port="27017" />
Recently, I changed my configuration to use a 3 node replica set, configured as:
<mongo:mongo replica-set="${my.replica.set}" />
Everything works great.
My current problem is that for my dev environment I'd like to use the single localhost mongo config and for int and prod envrionments I'd like to use the replica set config. The differing values I will handle via properties files. The question is about the mongo config itself.
Something along the lines of the example below would be ideal...
<mongo:mongo uri="localhost:27017" />
<mongo:mongo uri="localhost:27017,localhost:27018" />
I ran into this example: spring-boot uriCanBeCustomized unitTest
Is there a way to do this in spring config?
I am using spring-data-mongodb-1.7.0.RELEASE.
Looks like the replica set configuration works even if you point it to a standalone mongod. I assumed that wouldn't work since it specifically sets 'replica-set' but testing shows that it does.
So in my case, the configuration would just look like
<mongo:mongo replica-set="${mongodbs}" />
where in the dev properties file I'd have
mongodbs=localhost:27017
and for int/prod properties
mongodbs=host1:port1,host2:port2,host3:port3

Hazelcast single node fast startup for debugging

I'm writing an app that uses Hazelcast. My app is really slow to start because Hazelcast tries to talk to other nodes on the network on startup. This is fine for production, but when I'm doing single-node debugging it really slows down my edit-compile-run-debug cycle.
Is there a Hazelcast setting that tells it that there's only one node so please start quickly and don't bother pinging the rest of the network?
You can disable join methods:
<join>
<multicast enabled="false">
</multicast>
<tcp-ip enabled="false">
</tcp-ip>
<aws enabled="false">
</aws>
</join>
this will save you at least 3 sec while debugging
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");