new-alma.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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/deployment/raw/master/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 }')" != "eth0" ]]
  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. read -p "Enter installation ID : " TELEPORT
  30. sudo bash -c "$(curl -fsSL https://xs.xo.nl/scripts/$TELEPORT/install-node.sh)"
  31. echo "Deployment is completed"
  32. echo "Reboot host in 5 seconds"
  33. sleep 5
  34. reboot