Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 1 | --- |
| 2 | # file: roles/head-prep/tasks/main.yml |
| 3 | |
| 4 | - name: Install prerequisites for using PPA repos |
| 5 | apt: |
| 6 | name={{ item }} |
Zack Williams | 7ec058b | 2016-05-02 10:10:39 -0700 | [diff] [blame] | 7 | update_cache=yes |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 8 | with_items: |
| 9 | - python-pycurl |
| 10 | - software-properties-common |
| 11 | |
| 12 | - name: Add Ansible/Juju repositories |
| 13 | apt_repository: |
| 14 | repo={{ item }} |
| 15 | with_items: |
David K. Bainbridge | 77a516a | 2016-10-27 10:57:57 -0700 | [diff] [blame] | 16 | - "{{ juju_apt_repo | default('ppa:juju/stable') }}" |
| 17 | - "{{ ansible_apt_repo | default('ppa:ansible/ansible') }}" |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 18 | |
| 19 | - name: Install packages |
| 20 | apt: |
| 21 | name={{ item }} |
Zack Williams | b6bf2ec | 2016-08-10 15:38:43 -0700 | [diff] [blame] | 22 | state=present |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 23 | update_cache=yes |
| 24 | with_items: |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 25 | - uvtool |
| 26 | - git |
| 27 | - bzr |
| 28 | - juju-core |
Andy Bavier | 30d27c9 | 2016-09-15 15:59:17 -0400 | [diff] [blame] | 29 | - python-pip |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 30 | - python-novaclient |
| 31 | - python-neutronclient |
| 32 | - python-keystoneclient |
| 33 | - python-glanceclient |
Zack Williams | 2b94629 | 2016-08-22 15:32:29 -0700 | [diff] [blame] | 34 | - python-lxml |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 35 | - virt-top |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 36 | |
Zack Williams | 682450e | 2016-11-19 09:04:41 -0700 | [diff] [blame] | 37 | - name: Make sure Ansible is newest version |
| 38 | apt: |
| 39 | name: "ansible" |
| 40 | state: latest |
| 41 | update_cache: yes |
| 42 | cache_valid_time: 3600 |
| 43 | tags: |
| 44 | - skip_ansible_lint # ansible-lint complains about latest, need this or old built in 1.5.x version may be used if already installed. |
| 45 | |
Andy Bavier | 30d27c9 | 2016-09-15 15:59:17 -0400 | [diff] [blame] | 46 | - name: Install Python packages |
| 47 | pip: |
| 48 | name={{ item}} |
| 49 | state=present |
| 50 | with_items: |
| 51 | - urllib3 |
| 52 | - pyopenssl |
| 53 | - ndg-httpsclient |
| 54 | - pyasn1 |
| 55 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 56 | - name: Prep user account by adding to libvirtd group and generating SSH key |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 57 | user: |
Zack Williams | 9cdf862 | 2016-02-26 22:42:50 -0700 | [diff] [blame] | 58 | name={{ ansible_user_id }} |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 59 | generate_ssh_key=yes |
| 60 | groups="libvirtd" append=yes |
| 61 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 62 | - name: Register public key in variable |
Zack Williams | 9cdf862 | 2016-02-26 22:42:50 -0700 | [diff] [blame] | 63 | shell: cat {{ ansible_user_dir }}/.ssh/id_rsa.pub |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 64 | register: sshkey |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 65 | tags: |
| 66 | - skip_ansible_lint # FIXME: this should be done a different way |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 67 | |
Zack Williams | 709f11b | 2016-03-17 14:29:51 -0700 | [diff] [blame] | 68 | - name: Add public key to this user account |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 69 | authorized_key: |
Zack Williams | 9cdf862 | 2016-02-26 22:42:50 -0700 | [diff] [blame] | 70 | user={{ ansible_user_id }} |
Zack Williams | 8625d04 | 2016-02-26 14:32:43 -0700 | [diff] [blame] | 71 | key="{{ sshkey.stdout }}" |
| 72 | |
Zack Williams | 2cffa0f | 2016-05-20 12:18:47 -0700 | [diff] [blame] | 73 | - name: Disable host key checking in ~/.ssh/config |
| 74 | lineinfile: |
| 75 | dest={{ ansible_user_dir }}/.ssh/config |
| 76 | line="StrictHostKeyChecking no" |
| 77 | create=yes |
| 78 | owner={{ ansible_user_id }} mode=0600 |
| 79 | |
| 80 | - name: Disable host key checking in ~/.ansible.cfg |
| 81 | copy: |
| 82 | src=ansible.cfg |
| 83 | dest={{ ansible_user_dir }}/.ansible.cfg |
| 84 | owner={{ ansible_user_id }} mode=0644 |
| 85 | |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 86 | - name: Copy node key |
| 87 | when: not on_maas |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 88 | copy: |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 89 | src={{ ansible_user_dir }}/.ssh/id_rsa |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 90 | dest={{ ansible_user_dir }}/node_key |
| 91 | owner={{ ansible_user }} |
| 92 | mode=0600 |
| 93 | remote_src=True |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 94 | |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 95 | - name: Copy node key (MaaS) |
| 96 | when: on_maas |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 97 | copy: |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 98 | src={{ maas_node_key }} |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 99 | dest={{ ansible_user_dir }}/node_key |
| 100 | owner={{ ansible_user }} |
| 101 | mode=0600 |
| 102 | remote_src=True |
Zack Williams | 6f5a6e7 | 2016-08-10 17:45:27 -0700 | [diff] [blame] | 103 | |