How to access roster file data from an SLS file - salt-stack

I am using salt-ssh to configure salt-minions.
I need the IP address of the minion in the mid of the state file execution to put it in some configuration files.
My problem is that I can't use the grains to get this information as there will be multiple network interfaces and multiple IPs and the only fact I know is that the IP of the minion will be the IP in the roster file from which the salt-master did the ssh in to the minion.
How can I get this information?
How should I go about it?

I don't think this is possible at the moment, unfortunately. That might be a nice feature, though.

Related

Salt-minion tries to connect old salt-master instead of new salt-master

I had connected the salt master (10.1.x.x) to salt minion (10.2.x.x). Now I have changed the salt master(131.x.x.x) for existing salt minion and also I have changed the public key of new salt master in place /etc/salt/pki/minion. But the salt master still tring to connect old master . I checked in minion configuration file , no ip was configured for saltmaster. Can anyone tell me how did the salt-minion picks salt-master ip?
Salt minions will by default try to connect to a hostname called salt. If no IP is specified, and if minion is able to resolve salt, it will attempt to join that master.
It's possible that the hostname salt is pointing to old master's IP address. Something simple like ping salt from minion should be able to reveal some clues.
If it is indeed pointing to 10.1.x.x, then you have to change the DNS entry or etc/hosts entry to point to the new IP 131.x.x.x.

VM on GCP Lost network after set static ip in ifcfg-eth0

CentOs 7 with whm
Compute Engine VM Instance was working fine and GCP given external static ip xx.135 and internal 10.xx.x.2
Upon checking it is found that network settings was DHCP hence I
modified /etc/sysconfig/network-scripts/ifcfg-eth0 with BOOTPROTO=static with static ip given by GCP and restart network service. After that I lost the
control of VM. What is wrong? How to resolve the issues and get the control?
I do not think you needed to modify the DHCP configuration. You could follow the link here for Reserving a Static External IP Address. Also, this is the documentation if you would like to Reserve a Static Internal IP Address.
The way to fix a messed up config like this is to use the console, where the user can revert that config. Just to note here that you might have to have set the password. This is, in fact, one way.
Another way is if the disk attached is a Persistent Disk, you could attach it somewhere else and replace the config. Here is the documentation for that. There is a caution, some types of VMs that won't allow for this. It won't work if it's a local SSD.

way to detect list of changes in ip address in client machine

Ours is a small network consisting of 15 users. We have LAN messenger installed in every machine. Someone is misusing it by using anonymous IP address in their system. We traced the anonymous IP as 192.168.0.155. Now we want to check each system if they have manually changed their IP to the above address. Does Windows stores IP address change event anywhere? All are static IP within a LAN.
With some luck, I've got an easy solution for you to retrieve some information about the target. You could try to use the nbtstat-command.
Just open a command prompt and type in the following:
nbtstat -A 192.168.0.155
This will output a bunch of information about the target host, including the machinename and MAC address.
Here is an example, how the output could look like:
(source: onlinecomputertips.com)
Good luck

Find name of machine on which I've connected via ssh

I've ssh'd into one of my school's computer clusters. I'd like to know the name of the machine on which I'm running, e.g. myth14.
The hostname command will do this.

Copy files through specific Lan card of the source server

I want to copy backup from one server to another on daily bases. I would like to create any Script or SSIS package to do so. I cannot run that script from the destination server.
The source server has two LAN cards connected to the network with different IPs (obviously). One IP is used by the application and I want to use the other IP to copy the backup so that it may not affect the application performance.
Could you please guide me that how will I specy the specific IP of the source server through which i can copy the data to the destination server?
Thanks!
I'll call the two NICs Primary and Secondary. Primary is your NIC for your application. Secondary is your management NIC.
One approach you can use is to configure two DNS names for your host, one per IP address, with at least two IP addresses, one on each NIC. With the name that resolves to the IP address which is on the Secondary NIC (secondary.example.com), would this work for you?
strarc64 -c -mf backup.bin \\secondary.example.com\c$\path\to\backup
You can get strarc/strarc64 from here, and its usage here

Resources