blob: ee265bea33a2ca4004f9fe554fb2ce724192a9ed [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:
Zack Williams8625d042016-02-26 14:32:43 -070027 - uvtool
28 - git
29 - bzr
30 - juju-core
Andy Bavier30d27c92016-09-15 15:59:17 -040031 - python-pip
Zack Williams8625d042016-02-26 14:32:43 -070032 - python-novaclient
33 - python-neutronclient
34 - python-keystoneclient
35 - python-glanceclient
Zack Williams2b946292016-08-22 15:32:29 -070036 - python-lxml
Zack Williams709f11b2016-03-17 14:29:51 -070037 - virt-top
Zack Williams8625d042016-02-26 14:32:43 -070038
Zack Williams682450e2016-11-19 09:04:41 -070039- name: Make sure Ansible is newest version
40 apt:
41 name: "ansible"
42 state: latest
43 update_cache: yes
44 cache_valid_time: 3600
45 tags:
46 - skip_ansible_lint # ansible-lint complains about latest, need this or old built in 1.5.x version may be used if already installed.
47
Andy Bavier30d27c92016-09-15 15:59:17 -040048- name: Install Python packages
49 pip:
50 name={{ item}}
51 state=present
52 with_items:
53 - urllib3
54 - pyopenssl
55 - ndg-httpsclient
56 - pyasn1
57
Zack Williams709f11b2016-03-17 14:29:51 -070058- name: Prep user account by adding to libvirtd group and generating SSH key
Zack Williams8625d042016-02-26 14:32:43 -070059 user:
Zack Williams9cdf8622016-02-26 22:42:50 -070060 name={{ ansible_user_id }}
Zack Williams8625d042016-02-26 14:32:43 -070061 generate_ssh_key=yes
62 groups="libvirtd" append=yes
63
Zack Williams709f11b2016-03-17 14:29:51 -070064- name: Register public key in variable
Zack Williams9cdf8622016-02-26 22:42:50 -070065 shell: cat {{ ansible_user_dir }}/.ssh/id_rsa.pub
Zack Williams8625d042016-02-26 14:32:43 -070066 register: sshkey
Zack Williams35624562016-08-28 17:12:26 -070067 tags:
68 - skip_ansible_lint # FIXME: this should be done a different way
Zack Williams8625d042016-02-26 14:32:43 -070069
Zack Williams709f11b2016-03-17 14:29:51 -070070- name: Add public key to this user account
Zack Williams8625d042016-02-26 14:32:43 -070071 authorized_key:
Zack Williams9cdf8622016-02-26 22:42:50 -070072 user={{ ansible_user_id }}
Zack Williams8625d042016-02-26 14:32:43 -070073 key="{{ sshkey.stdout }}"
74
Zack Williams2cffa0f2016-05-20 12:18:47 -070075- name: Disable host key checking in ~/.ssh/config
76 lineinfile:
77 dest={{ ansible_user_dir }}/.ssh/config
78 line="StrictHostKeyChecking no"
79 create=yes
80 owner={{ ansible_user_id }} mode=0600
81
82- name: Disable host key checking in ~/.ansible.cfg
83 copy:
84 src=ansible.cfg
85 dest={{ ansible_user_dir }}/.ansible.cfg
86 owner={{ ansible_user_id }} mode=0644
87
Zack Williams35624562016-08-28 17:12:26 -070088- name: Copy node key
89 when: not on_maas
Andy Bavier6274d6a2016-08-12 18:12:01 -040090 copy:
Zack Williams35624562016-08-28 17:12:26 -070091 src={{ ansible_user_dir }}/.ssh/id_rsa
Andy Bavier6274d6a2016-08-12 18:12:01 -040092 dest={{ ansible_user_dir }}/node_key
93 owner={{ ansible_user }}
94 mode=0600
95 remote_src=True
Andy Bavier6274d6a2016-08-12 18:12:01 -040096
Zack Williams35624562016-08-28 17:12:26 -070097- name: Copy node key (MaaS)
98 when: on_maas
Andy Bavier6274d6a2016-08-12 18:12:01 -040099 copy:
Zack Williams35624562016-08-28 17:12:26 -0700100 src={{ maas_node_key }}
Andy Bavier6274d6a2016-08-12 18:12:01 -0400101 dest={{ ansible_user_dir }}/node_key
102 owner={{ ansible_user }}
103 mode=0600
104 remote_src=True
Zack Williams6f5a6e72016-08-10 17:45:27 -0700105