blob: b22888d96f4474eab58e0808843dca96d334a0c6 [file] [log] [blame]
Zack Williams8625d042016-02-26 14:32:43 -07001---
2# file: roles/head-prep/tasks/main.yml
3
4- name: Install prerequisites for using PPA repos
5 apt:
6 name={{ item }}
Zack Williams7ec058b2016-05-02 10:10:39 -07007 update_cache=yes
8 cache_valid_time=3600
Zack Williams8625d042016-02-26 14:32:43 -07009 with_items:
10 - python-pycurl
11 - software-properties-common
12
13- name: Add Ansible/Juju repositories
14 apt_repository:
15 repo={{ item }}
16 with_items:
David K. Bainbridge77a516a2016-10-27 10:57:57 -070017 - "{{ juju_apt_repo | default('ppa:juju/stable') }}"
18 - "{{ ansible_apt_repo | default('ppa:ansible/ansible') }}"
Zack Williams8625d042016-02-26 14:32:43 -070019
20- name: Install packages
21 apt:
22 name={{ item }}
Zack Williamsb6bf2ec2016-08-10 15:38:43 -070023 state=present
Zack Williams8625d042016-02-26 14:32:43 -070024 update_cache=yes
Zack Williams1320e1f2016-05-02 09:54:08 -070025 cache_valid_time=3600
Zack Williams8625d042016-02-26 14:32:43 -070026 with_items:
27 - ansible
28 - uvtool
29 - git
30 - bzr
31 - juju-core
Andy Bavier30d27c92016-09-15 15:59:17 -040032 - python-pip
Zack Williams8625d042016-02-26 14:32:43 -070033 - python-novaclient
34 - python-neutronclient
35 - python-keystoneclient
36 - python-glanceclient
Zack Williams2b946292016-08-22 15:32:29 -070037 - python-lxml
Zack Williams709f11b2016-03-17 14:29:51 -070038 - virt-top
Zack Williams8625d042016-02-26 14:32:43 -070039
Andy Bavier30d27c92016-09-15 15:59:17 -040040- name: Install Python packages
41 pip:
42 name={{ item}}
43 state=present
44 with_items:
45 - urllib3
46 - pyopenssl
47 - ndg-httpsclient
48 - pyasn1
49
Zack Williams709f11b2016-03-17 14:29:51 -070050- name: Prep user account by adding to libvirtd group and generating SSH key
Zack Williams8625d042016-02-26 14:32:43 -070051 user:
Zack Williams9cdf8622016-02-26 22:42:50 -070052 name={{ ansible_user_id }}
Zack Williams8625d042016-02-26 14:32:43 -070053 generate_ssh_key=yes
54 groups="libvirtd" append=yes
55
Zack Williams709f11b2016-03-17 14:29:51 -070056- name: Register public key in variable
Zack Williams9cdf8622016-02-26 22:42:50 -070057 shell: cat {{ ansible_user_dir }}/.ssh/id_rsa.pub
Zack Williams8625d042016-02-26 14:32:43 -070058 register: sshkey
Zack Williams35624562016-08-28 17:12:26 -070059 tags:
60 - skip_ansible_lint # FIXME: this should be done a different way
Zack Williams8625d042016-02-26 14:32:43 -070061
Zack Williams709f11b2016-03-17 14:29:51 -070062- name: Add public key to this user account
Zack Williams8625d042016-02-26 14:32:43 -070063 authorized_key:
Zack Williams9cdf8622016-02-26 22:42:50 -070064 user={{ ansible_user_id }}
Zack Williams8625d042016-02-26 14:32:43 -070065 key="{{ sshkey.stdout }}"
66
Zack Williams2cffa0f2016-05-20 12:18:47 -070067- name: Disable host key checking in ~/.ssh/config
68 lineinfile:
69 dest={{ ansible_user_dir }}/.ssh/config
70 line="StrictHostKeyChecking no"
71 create=yes
72 owner={{ ansible_user_id }} mode=0600
73
74- name: Disable host key checking in ~/.ansible.cfg
75 copy:
76 src=ansible.cfg
77 dest={{ ansible_user_dir }}/.ansible.cfg
78 owner={{ ansible_user_id }} mode=0644
79
Zack Williams35624562016-08-28 17:12:26 -070080- name: Copy node key
81 when: not on_maas
Andy Bavier6274d6a2016-08-12 18:12:01 -040082 copy:
Zack Williams35624562016-08-28 17:12:26 -070083 src={{ ansible_user_dir }}/.ssh/id_rsa
Andy Bavier6274d6a2016-08-12 18:12:01 -040084 dest={{ ansible_user_dir }}/node_key
85 owner={{ ansible_user }}
86 mode=0600
87 remote_src=True
Andy Bavier6274d6a2016-08-12 18:12:01 -040088
Zack Williams35624562016-08-28 17:12:26 -070089- name: Copy node key (MaaS)
90 when: on_maas
Andy Bavier6274d6a2016-08-12 18:12:01 -040091 copy:
Zack Williams35624562016-08-28 17:12:26 -070092 src={{ maas_node_key }}
Andy Bavier6274d6a2016-08-12 18:12:01 -040093 dest={{ ansible_user_dir }}/node_key
94 owner={{ ansible_user }}
95 mode=0600
96 remote_src=True
Zack Williams6f5a6e72016-08-10 17:45:27 -070097