Skip to content
Snippets Groups Projects
Commit d848ca62 authored by jurgenhaas's avatar jurgenhaas
Browse files

Allow inithost to work with different initial auth methods

parent 53799340
No related branches found
No related tags found
No related merge requests found
......@@ -5,13 +5,26 @@ cd $( cd $(dirname $(realpath $0)) ; pwd )
if [ "$2" == "" ]
then
echo "Usage"
echo "inithost.sh HOST IP"
echo "inithost.sh HOST IP [USER [KEYFILE]]"
exit 101;
fi
HOST=$1
IP=$2
ROOT=root
KEYFILE=--ask-pass
shift
shift
if [ "$1" != "" ]
then
ROOT=$1
shift
fi
if [ "$1" != "" ]
then
KEYFILE=--private-key=$1
shift
fi
./ansible-playbook.sh inithost --ask-pass --extra-vars="host=$HOST inithostip=$IP" --tags="prepare" "$@"
./ansible-playbook.sh inithost --extra-vars="inituser=$ROOT host=$HOST inithostip=$IP firstuser=$USER" --tags="prepare" $KEYFILE "$@"
./ansible-playbook.sh inithost --extra-vars="host=$HOST inithostip=$IP distribute_keys=true" --tags="config" "$@"
......@@ -18,7 +18,7 @@
- '{{ inithostip }}'
- '{{ host }}'
- name: "InitHost | Copy root id to new host"
shell: "ssh-copy-id -i root@{{ inithostip }} -o PasswordAuthentication=yes -o PubkeyAuthentication=no"
shell: "ssh-copy-id -i root@{{ inithostip }} -o PasswordAuthentication=yes -o PubkeyAuthentication=no -o IdentitiesOnly=yes"
register: inithost_ssh_copy_id
changed_when: "inithost_ssh_copy_id.rc != 0"
failed_when: false
......@@ -35,17 +35,18 @@
lineinfile:
dest=/etc/hosts
regexp="^{{ inithostip }} "
line={{ inithostip }} {{ host }}
line="{{ inithostip }} {{ host }}"
- name: "Setup first user"
hosts: "{{ host }}"
gather_facts: false
user: root
user: "{{ inituser }}"
sudo: yes
tags:
- prepare
vars:
first_user:
- name: "{{ lookup('env','USER') }}"
- name: "{{ firstuser }}"
password: "{{ ansible_sudo_pass|password_hash('sha512') }}"
tasks:
- name: "InitHost | Create first user"
......@@ -71,6 +72,7 @@
- name: "Security setup"
hosts: "{{ host }}"
gather_facts: true
sudo: yes
tags:
- config
......
......@@ -112,3 +112,6 @@
- option: "scp_if_ssh"
value: "True"
section: "ssh_connection"
- option: "ssh_args"
value: "-o IdentitiesOnly=yes"
section: "ssh_connection"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment