summaryrefslogtreecommitdiffstats
path: root/vagrant/roles/local.prep/tasks/main.yml
blob: ddef820172e55c7c9c4f3869905edf423c8c2582 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
- name: Generate distro-vars.yml in ansible directory
  block:
    - set_fact:
        t:
          distro: "{{ distro }}"
    - copy:
        content: '{{ t| to_nice_yaml }}'
        dest: ./ansible/distro-vars.yml

- name: copy vagrant generated inventory file - local machine
  copy:
    src: .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
    dest: ./vagrant_ansible_inventory

- name: adapt inventory - ssh options
  blockinfile:
    path: ./vagrant_ansible_inventory
    block: |
      [all:vars]
      ansible_ssh_common_args='-o StrictHostKeyChecking=no'

- name: copy vagrant generated inventory file - setup machine
  copy:
    src: ./vagrant_ansible_inventory
    dest: ./ansible/vagrant_ansible_inventory

- name: adapt inventory - correct ssh key
  replace:
    path: ./ansible/vagrant_ansible_inventory
    regexp: "ansible_ssh_private_key_file='.*/\\.vagrant\\.d/insecure_private_key'"
    replace: "ansible_ssh_private_key_file='/home/vagrant/ansible/vagrant_insecure_private_ssh_key'"

- name: dump ssh config
  command: vagrant ssh-config
  register: output

- name: store ssh-config in file
  copy:
    content: "{{ output.stdout }}\n"
    dest: ./ssh-config-host

- name: copy ssh-config for setup
  copy:
   src: ./ssh-config-host
   dest: ./ansible/ssh-config-setup

- name: modify ssh-config-setup
  replace:
    path: ./ansible/ssh-config-setup
    regexp: "IdentityFile .*"
    replace: "IdentityFile /home/vagrant/ansible/vagrant_insecure_private_ssh_key"