AWX ansible - Allow inventory duplicate host - ansible-awx

AWX version 13.
I have a few inventories, each one can have a many hosts and I will be adding a lot more hosts over time. Some hosts have unique IP's, while others share the same IP. Each host I've set a variable in the variables section with the ssh port to use when connecting to it for the job and this works well.
To work around the issue I'm creating a unique DNS record for the hosts that share the same IP and using the DNS in the host field for that host, but there has to be a better way.
How can I share or have AWX ignore the duplicate host IP/dns and let me save the duplicate host record?

Related

Change Hostnames and IP Addresses with another host - Does it require a DNS update?

I have a new Linux database server I am working on with a certain hostname and ipaddress. I want to change it's hostname and ipaddress with my old Linux database server's at the time of going live with the new server. I understand this requires only update on the new server's hosts file.
My team says it would need a DNS update. I don't see why it would require a DNS update. Because a DNS is a mapping between hostname and ipaddress and it hasn't changed.
Could anyone clarify?
Thank You, Madhuri Dara
normally, yes indeed, a DNS is a mapping between IP addresses and hostname.
However, I would also recommend to delete the old one an re-create them to perform a re-discovery of the routes.
The best option for you would be here to have a DNS manager into your domain, this way, you could modify them here, instead of into your DNS file in each machine.

Configure MongoDB DB Replica Sets using IP Addresses

Can I configure MongoDB DB replica sets using IP addresses alone instead of host names?
Usually an IP address can be used almost everywhere a host name is expected. But our main Mongo DB expert led me to believe that we must use hostnames sharing a common domain such as: db1.domain.com, db2.domain.com...
Documentation for replica set rs.initiate() does not say anything about this.
You can use IP addresses in replica set config however domain names are preferable:
The host field specifies the master mongod instance, and holds a resolvable hostname, i.e. IP address, or a name from a host file, or preferably a fully qualified domain name.
Host is defined here

ansible - how to pass local DNS server while running ansible-playbook to resolve hostname

I'm using ansible (ansible 1.9.0.1).
I'm running ansible-playbook to perform some operations on a target / remote machine using it's hostname.
My inventory file has an entry for a hostname i.e. appserver01.newdomainname.com
When I run ansible-playbook to just do a simple (hello world example), it doesn't resolve the hostname. If in the inventory file, I have the x.x.x.x IP, then it works!!!!
So, it seems like the nameserver or search in my source machine's /etc/resolv.conf is not resolving the remote hostname using it's fully qualified domain name i.e. appserver01.newdomainname.com
Is there any way I can call ansible-playbook and pass the new/local DNS server so that ansible can resolve the hostname (in the inventory file) from that DNS first (instead of reading / resolving it from the /etc/resolv.conf).
PS: I can't add this new/local DNS nameserver xx.xx.yy.zz to /etc/resolv.conf.
One way you could work around this would be to use the attribute ansible_ssh_host in your inventory file. This is not the same as connecting to your local DNS, but its kind of like transporting the DNS records with your inventory. This way you can still refer to your servers by their hostnames and you don't have to put anything in your servers hosts file. So it would look like this:
[myservers]
appserver01.newdomainname.com ansible_ssh_host=x.x.x.x
You could even move these mappings out to a host_vars file and keep a different list of IPs for each of your deployment environments.

How to fix local IP in Nat Configuration on WHM/Cpanel on Centos 6 on Google Compute Engine

If you deleted a VM on Google Compute Engine on a Centos 6 Cpanel server and then create it with the same disk, you often are assigned a new local IP address even if you kept the static IP. This does not properly update in the NAT configuration on Cpanel/WHM servers.
This stops any sites from working and the only way to fix it is manually edit the http.conf file. Inside Web Host Manager you can fix the public facing IP, but there is no place to edit the local IP. Does anyone know how to edit the nat configuration on centos 6 on Google Compute Engine to fix the local IP so that all new sites created will have the correct local IP in the http.conf?
Here is a pic of the current nat configuration on my Centos 6 server.
Here is a pic showing my correct local IP in Compute Engine, you can see it does not match the one Cpanel has, which causes the http.conf file to generate new virtual hosts with the wrong IP.
Its a configuration issue within WHM/Cpanel that can not be corrected with any configuration settings in the interfaces. I contacted Cpanel Support and they provided me with a command line shell script to run from root to fix the issue. It worked flawlessly:
# /scripts/build_cpnat
This resolved the issue, but they gave this additional info if that does not solve your problem:
If this does not resolve your issue, please review our NAT
documentation and ensure that your server is configured in a supported
1:1 NAT configuration:
http://documentation.cpanel.net/display/ALD/1%3A1+NAT
The Compute Engine does not allow you to create an instance with a specific network IP address. You will have to use a combination of routes and an instance's --can-ip-forward ability to add an IP address as a static network IP address that then maps to your desired virtual machine instance.
For example, if you want to assign 10.1.1.1 specifically as a network IP address to a virtual machine instance, you can create a static route that sends traffic from 10.1.1.1 to your instance, even if the instance's network IP address assigned by Compute Engine doesn't match your desired network IP address.
Take a look at this link: https://cloud.google.com/compute/docs/instances-and-network#staticnetworkaddress
The best and the simplest solution for this is to use the WHM/Cpanel IP Migration Wizard option to change the existing Private IP with the new one and then wait for few hours to make those changes propagate and you will see the new Private IP and Public IP in sync in your WHM platform.
I had the same issue with AWS and CentOS 7 hosting latest WHM/ cPanel. each time the instance restarts then a new private/ local IP address. I deleted cpnat from /var/cpanel/.
So I disabled the NAT, then I created another eth so I can configure it with static IP which is the Public IP, then for the main account only which own the hostname and domain name for WHM I assigned it to the local IP address, but as the local IP address keep changing so I created a script fires up at the start after each boot collecting the new local IP address and assign it automatically to the main account and if there is no new local IP address then the script exit without doing anything.
here are the steps been done:
nano /etc/sysconfig/network-scripts/ifcfg-eth0:cp1
and inside that file put the following: (change IPADDR & DNS)
DEVICE="eth0:cp1"
BOOTPROTO="static"
ONBOOT="yes"
IPADDR="13.54.100.XX"
NETMASK="255.255.255.0"
DNS1="172.31.0.2"
TYPE="Ethernet"
IPV6INIT="no"
now we would like this interface to stay upon reboot and start on the reboot so run:
ifup eth0:cp1
then restart the network service by:
service network restart
now disable NAT mode by deleting the file cpnat in /var/cpanel
now check the file /var/cpanel/mainip and make sure our external ip is there 13.54.100.XX
create the following file with nano:
nano /etc/init.d/fixdhcp
add the following to the file and save it:
#!/bin/bash
# # This script assigns available DHCP IP to ACCOUNT-NAME user on Reboot or Restart, please change ACCOUNT-NAME to the main WHM domain account name
# apache service will restart when done.
/scripts/rebuildippool
export mydhcp10=$(cat /etc/ipaddrpool)
echo $mydhcp10
# Exit if no available IPs
if [ "${mydhcp10}" == "" ]; then
echo "ipaddrpool is empty" && exit 1
else
echo "ipaddrpool is not empty"
fi
/usr/local/cpanel/bin/setsiteip -u ACCOUNT-NAME $mydhcp10
chmod +x /etc/rc.d/rc.local
echo finished now restarting services
/scripts/rebuildhttpdconf
/scripts/rebuildippool
/scripts/cleandns
/scripts/fixvaliases
/scripts/modify_accounts --theme=paper_lantern --all-users
/usr/local/cpanel/scripts/updateuserdomains
service httpd restart
make the file excutable:
chmod +x /etc/init.d/fixdhcp
add it to rc.d
nano /etc/rc.local
then add it like this:
/etc/init.d/fixdhcp
save then run:
chmod +x /etc/rc.d/rc.local
If it still won't change, try this:
(i.e. when you List Accounts you see the old internal IP listed for each account)
WHM -> List Accounts expand desired account (+)
=> Change IP Address
=> select the IP address (even if it is the same external IP)
=> click change.
repeat for each affected account.
output:
The remote dns zone is not consistent with the httpd.conf.
The current ip in httpd.conf is: 10.240.0.3.
The current ip in the dns zone is: 104.154.68.68!
104.154.68.68 will be switched to the new ip as well!
The local dns zone is not consistent with the httpd.conf.
The current ip in httpd.conf is: 10.240.0.3.
The current ip in the dns zone is: 10.240.0.2!
10.240.0.2 will be switched to the new ip as well!
Warning, serious database inconsistency. httpd.conf, local dns, and remote dns all
have different ideas about what the ip address of this site really is. They will now all be changed
to the new ip: 10.240.0.2!
Changed all instances of [10.240.0.3,104.154.68.68] -> [104.154.68.68] in dcmetroc.kellen.hosting
Changed all instances of [10.240.0.3,104.154.68.68] -> [104.154.68.68] in dcmetrocollaborative.org
Updating httpd.conf....Done
System has 0 free ips.
if you're using nginx, don't forget to rebuild vhosts in ngnix plugin!
I just needed to change the local IP with the new one in:
/var/cpanel/cpnat
/etc/hosts
/etc/ips.dnsmaster

configure mongodb only accept remote connection comes from LAN

mongodb has bind ip but it is not so practical due to when new server add, it need shutdown db and add the new server ip into bind ip list and restart db. This is unacceptable because all other servers need to relaunch either.
In almost all deployment, servers machine and db machine are in same LAN. So can mongodb be configured as only accept ranges of ip of [172.16.0.0 - 172.31.255.255], [192.168.0.0 - 192.168.255.255], [10.0.0.0 - 10.255.255.255]?
These 3 ranges ip is LAN ip
The bind_ip configuration value only determines which IP address(es) your MongoDB server is listening to. It does not control access from remote IPs -- that is the job of a firewall.
The address ranges you have listed as requiring remote access are all private IP address space which means these networks are not directly reachable/routable outside your LAN. Assuming you can route traffic between your private networks you should not need to bind to multiple IP addresses.
Given you are allowing access from a broad range of IP addresses, you should also read the Security section of the MongoDB manual (in particular, the Security Checklist and tutorial on enabling Access Control).
bindIp can accept multiple comma separated values. See the "Security considerations" section Here
Other than that you might want to consider configuring your firewall, maybe iptables if it runs on Linux machine.
Hope this helps