replace hard-coded usernames with remote_user variable
This commit is contained in:
parent
ee4a13c926
commit
ad8e3cc155
@ -34,40 +34,40 @@
|
||||
- name: create vm definitions
|
||||
template:
|
||||
src: "roles/terraform/files/cloud-init.tf.j2"
|
||||
dest: "/home/hybris/terraform/{{ item.hostname }}.tf"
|
||||
owner: hybris
|
||||
group: hybris
|
||||
dest: "/home/{{ remote_user }}/terraform/{{ item.hostname }}.tf"
|
||||
owner: {{ remote_user }}
|
||||
group: {{ remote_user }}
|
||||
with_items: "{{ kubernetes }}"
|
||||
|
||||
- name: create cloud-init config
|
||||
template:
|
||||
src: "roles/terraform/files/cloud-init.cfg.j2"
|
||||
dest: "/home/hybris/terraform/{{ item.hostname }}.cloud_init.cfg"
|
||||
owner: hybris
|
||||
group: hybris
|
||||
dest: "/home/{{ remote_user }}/terraform/{{ item.hostname }}.cloud_init.cfg"
|
||||
owner: {{ remote_user }}
|
||||
group: {{ remote_user }}
|
||||
with_items: "{{ kubernetes }}"
|
||||
|
||||
- name: create libvirt_provider config
|
||||
copy:
|
||||
src: roles/terraform/files/libvirt_provider.tf
|
||||
dest: /home/hybris/terraform/libvirt_provider.tf
|
||||
dest: /home/{{ remote_user }}/terraform/libvirt_provider.tf
|
||||
|
||||
- name: delete statefile if it exists
|
||||
file:
|
||||
path: /home/hybris/terraform/terraform.tfstate
|
||||
path: /home/{{ remote_user }}/terraform/terraform.tfstate
|
||||
state: absent
|
||||
|
||||
- name: initialize terraform
|
||||
shell: terraform init
|
||||
args:
|
||||
chdir: /home/hybris/terraform
|
||||
chdir: /home/{{ remote_user }}/terraform
|
||||
|
||||
- name: plan terraform
|
||||
shell: terraform plan -out=cloud-init-plan
|
||||
args:
|
||||
chdir: /home/hybris/terraform
|
||||
chdir: /home/{{ remote_user }}/terraform
|
||||
|
||||
- name: apply terraform
|
||||
shell: terraform apply "cloud-init-plan"
|
||||
args:
|
||||
chdir: /home/hybris/terraform
|
||||
chdir: /home/{{ remote_user }}/terraform
|
||||
|
8
roles/kubernetes/files/kubernetes.repo
Normal file
8
roles/kubernetes/files/kubernetes.repo
Normal file
@ -0,0 +1,8 @@
|
||||
[kubernetes]
|
||||
name=Kubernetes
|
||||
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
repo_gpgcheck=1
|
||||
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
|
||||
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
|
@ -47,6 +47,8 @@
|
||||
#### KERNEL TASKS ####
|
||||
######################
|
||||
|
||||
|
||||
# TODO: get rid of inline http_proxy and fetch repo with the yum-repository ansible module
|
||||
- name: import elrepo gpg key
|
||||
shell: rpm -httpproxy http://[2001:470:6d:22c::1]:3128 --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
|
||||
|
||||
@ -120,9 +122,10 @@
|
||||
- name: add docker-ce yum repository
|
||||
shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
|
||||
|
||||
- name: copy kubernetes repo config
|
||||
copy:
|
||||
src: /Users/hybris/dev/k8s-ansible/files/kubernetes.repo
|
||||
src: ../files/kubernetes.repo
|
||||
dest: /etc/yum.repos.d/kubernetes.repo
|
||||
|
||||
- name: install packages
|
||||
|
@ -1,6 +1,6 @@
|
||||
#cloud-config
|
||||
users:
|
||||
- name: hybris
|
||||
- name: {{ remote_user }}
|
||||
lock-passwd: false
|
||||
passwd: $1$tG6Uv4$BPCIRF6RFuLrJ.lQO1GB8.
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
@ -12,9 +12,9 @@ write_files:
|
||||
# inet6_addr=$(ip a s | grep "inet6 2001:470:6d:22c:" | awk '{print substr($2,0)}')
|
||||
sudo hostnamectl set-hostname {{ item.hostname }}
|
||||
sudo ip -6 addr add {{ item.ipv6 }}/64 dev eth0
|
||||
sudo chown -R hybris:hybris /home/hybris
|
||||
path: /home/hybris/cloud-init.sh
|
||||
owner: hybris:hybris
|
||||
sudo chown -R {{ remote_user }}:{{ remote_user }} /home/{{ remote_user }}
|
||||
path: /home/{{ remote_user }}/cloud-init.sh
|
||||
owner: {{ remote_user }}:{{ remote_user }}
|
||||
permissions: '0744'
|
||||
runcmd:
|
||||
- [ '/home/hybris/cloud-init.sh' ]
|
||||
- [ '/home/{{ remote_user }}/cloud-init.sh' ]
|
||||
|
@ -36,32 +36,32 @@
|
||||
- name: go install terraform-provider-libvirt
|
||||
shell: /usr/local/go/bin/go install
|
||||
args:
|
||||
chdir: /home/hybris/go/src/github.com/dmacvicar/terraform-provider-libvirt
|
||||
chdir: /home/{{ remote_user }}/go/src/github.com/dmacvicar/terraform-provider-libvirt
|
||||
|
||||
- name: create terraform config directory
|
||||
file:
|
||||
path: /home/hybris/.terraform.d/
|
||||
path: /home/{{ remote_user }}/.terraform.d/
|
||||
state: directory
|
||||
|
||||
- name: create terraform plugin directory
|
||||
file:
|
||||
path: /home/hybris/.terraform.d/plugins
|
||||
path: /home/{{ remote_user }}/.terraform.d/plugins
|
||||
state: directory
|
||||
|
||||
- name: install terraform-provider-libvirt
|
||||
copy:
|
||||
src: /home/hybris/go/bin/terraform-provider-libvirt
|
||||
dest: /home/hybris/.terraform.d/plugins/terraform-provider-libvirt
|
||||
src: /home/{{ remote_user }}/go/bin/terraform-provider-libvirt
|
||||
dest: /home/{{ remote_user }}/.terraform.d/plugins/terraform-provider-libvirt
|
||||
mode: 0777
|
||||
owner: hybris
|
||||
owner: {{ remote_user }}
|
||||
remote_src: yes
|
||||
|
||||
- name: delete terraform directory
|
||||
file:
|
||||
path: /home/hybris/terraform
|
||||
path: /home/{{ remote_user }}/terraform
|
||||
state: absent
|
||||
|
||||
- name: create terraform directory
|
||||
file:
|
||||
path: /home/hybris/terraform
|
||||
path: /home/{{ remote_user }}/terraform
|
||||
state: directory
|
||||
|
Loading…
Reference in New Issue
Block a user