new-node.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. echo "Creating group"
  3. groupadd Ansible
  4. echo "Creating user"
  5. useradd -g Ansible -m -r -c \"Ansible user\" ansible
  6. echo "Set sudo rights"
  7. echo \"%Ansible ALL=(ALL) NOPASSWD: ALL\" > /etc/sudoers.d/Ansible
  8. echo "Set remote access"
  9. mkdir /home/ansible/.ssh
  10. chmod 700 /home/ansible/.ssh
  11. curl -O /home/ansible/.ssh/authorized_keys https://git.xo.nl/marcel/deploy/ansible.pub
  12. chown -R ansible:Ansible /home/ansible/.ssh
  13. echo "Enabling IPv6"
  14. sed -i '/net.ipv6.conf.all.disable_ipv6.*/d' /etc/sysctl.conf && sysctl -q -p && echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  15. if [[ "$(ip -br link | grep -v UNKNOWN | grep -v DOWN | grep -v veth | grep -v br | awk '{ print $1 }')" != "eth1" ]]
  16. then
  17. echo "Configure GRUB"
  18. sed -i 's/GRUB_CMDLINE_LINUX=\"/GRUB_CMDLINE_LINUX=\"net.ifnames=0 /' /etc/default/grub
  19. grub2-mkconfig -o $(find /boot -name grub.cfg)
  20. mv /etc/sysconfig/network-scripts/ifcfg* /etc/sysconfig/network-scripts/ifcfg-eth0
  21. sed -i 's/NAME=.*/NAME=eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0
  22. sed -i 's/DEVICE=.*/DEVICE=eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0
  23. else
  24. echo "GRUB configuration not required"
  25. fi
  26. echo "Disable SELinux"
  27. sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
  28. echo "install Teleport agent"
  29. sudo bash -c "$(curl -fsSL https://xs.xo.nl/scripts/c368df0b0c8b08d92e3cfa66616c333a/install-node.sh)"
  30. echo "Deployment is completed"
  31. echo "Reboot host in 3 seconds"
  32. wait 3
  33. reboot