Separate tasks in kubernetes role

This commit is contained in:
hybris 2019-01-25 18:54:52 +01:00
parent 07afd3f694
commit be70ab72bb
5 changed files with 202 additions and 224 deletions

View file

@ -1,67 +1,56 @@
---
- name: install packages
yum:
name:
- libvirt-devel
- git
- gcc
- unzip
state: present
become: yes
- name: download and install terraform 0.11.11 release
unarchive:
src: https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip
dest: /usr/local/bin
remote_src: yes
become: yes
- name: remove files and directories
file:
path: "/home/{{ ansible_ssh_user }}/terraform/"
state: "{{ item }}"
with_items:
- absent
- directory
- name: download and install golang 1.11.4 release
unarchive:
src: https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz
dest: /usr/local
remote_src: yes
become: yes
- name: "download qcow2 cloud image"
copy:
src: "/home/{{ ansible_ssh_user }}/images/{{ source_cloud_image_name }}"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ source_cloud_image_name }}"
remote_src: yes
- name: export path
lineinfile:
path: /etc/profile
regexp: '^export PATH=$PATH:/usr/local/go/bin'
line: 'export PATH=$PATH:/usr/local/go/bin'
become: yes
- name: create vm definitions
template:
src: "../files/cloud-init.tf.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.tf"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items: "{{ kubernetes }}"
- name: go get terraform-provider-libvirt
shell: /usr/local/go/bin/go get github.com/dmacvicar/terraform-provider-libvirt
- name: create cloud-init config
template:
src: "../files/cloud-init.cfg.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.cloud_init.cfg"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items: "{{ kubernetes }}"
- name: go install terraform-provider-libvirt
shell: /usr/local/go/bin/go install
args:
chdir: /home/{{ remote_user }}/go/src/github.com/dmacvicar/terraform-provider-libvirt
- name: create cloud-init network config
template:
src: "../files/cloud-init-network.cfg.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/{{ item.hostname }}.cloud_init_network.cfg"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
with_items: "{{ kubernetes }}"
- name: create terraform config directory
file:
path: /home/{{ remote_user }}/.terraform.d/
state: directory
- name: create libvirt_provider config
template:
src: "../files/libvirt_provider.tf.j2"
dest: "/home/{{ ansible_ssh_user }}/terraform/libvirt_provider.tf"
owner: "{{ ansible_ssh_user }}"
group: "{{ ansible_ssh_user }}"
- name: create terraform plugin directory
file:
path: /home/{{ remote_user }}/.terraform.d/plugins
state: directory
- name: initialize terraform
shell: terraform init
args:
chdir: /home/{{ ansible_ssh_user }}/terraform/
- name: install terraform-provider-libvirt
copy:
src: /home/{{ remote_user }}/go/bin/terraform-provider-libvirt
dest: /home/{{ remote_user }}/.terraform.d/plugins/terraform-provider-libvirt
mode: 0777
owner: {{ remote_user }}
remote_src: yes
- name: delete terraform directory
file:
path: /home/{{ remote_user }}/terraform
state: absent
- name: create terraform directory
file:
path: /home/{{ remote_user }}/terraform
state: directory
- name: terraform deploy
terraform:
project_path: /home/{{ ansible_ssh_user }}/terraform
state: present