Mirror all redhat 7 repositories

First ,make sure you have a system that is registered, then run this script

#!/bin/bash
(
grep ‘\[‘ /etc/yum.repos.d/redhat.repo | sed ‘s/\[//g;s/\]//g’ | while read repo;do
reposync –gpgcheck -l –repoid=$repo –download_path=/swdepot/repos/ –downloadcomps –download-metadata
done
for d in $(ls /swdepot/repos);do
cd /swdepot/repos/$d
createrepo -v /swdepot/repos/$d
done
) >>/var/log/reposync.log 2>&1

setup CentOS7 as dns forwarding

yum install bind
vi /etc/named.conf
found
———–
zone “.” IN {
type hint;
file “named.ca”;
};
———–
replace with
———–
zone “.” IN {
type forward;
forward only;
forwarders { 8.8.8.8; 8.8.4.4; };
};
———–
service named start

also change the ip address to the server’s ip address, and make sure to set the allow-query settings properly

options {
listen-on port 53 { 192.168.5.100; };
allow-query { localhost;any; };

Mysql-Ansible connection example

– name: Retrieve stuff from mysql
command: >
mysql –user=alice –password=topsecret dbname
–host=147.102.160.1 –batch –skip-column-names
–execute=”SELECT stuff from stuff_table”
register: stuff
check_mode: no
changed_when: False

– name: Do something with stuff
debug: “{{ item }}”
with_items: stuff.stdout_lines

#—— another example
– name: Get username
command: mysql -u {{ username }} -p {{ mysql_root_password }} {{ database }} -Ns -e “
register: username

– debug: msg=”{{ username.stdout_lines }}”

windows setup for winrm, for Ansible

In order for Ansible to connect to your windows server, you need to open winrm,you can do it by putting the settings inn a ps1 (/var/www/html/w.ps1) file in your webserver with these contents:

Enable-PSRemoting
Set-Item -Path “WSMan:\localhost\Service\Auth\Basic” -value True
Set-Item -Path “WSMan:\localhost\Service\AllowUnencrypted” -value True
net localgroup “Remote Management Users” my_admin /add
net localgroup administrators my_admin /add

Then in the windows server, you can get it and run it using:
powershell “IEX(New-Object Net.WebClient).downloadString(‘http://10.4.192.192/w.ps1’)”