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
|
- name: create vm definitions
|
||||||
template:
|
template:
|
||||||
src: "roles/terraform/files/cloud-init.tf.j2"
|
src: "roles/terraform/files/cloud-init.tf.j2"
|
||||||
dest: "/home/hybris/terraform/{{ item.hostname }}.tf"
|
dest: "/home/{{ remote_user }}/terraform/{{ item.hostname }}.tf"
|
||||||
owner: hybris
|
owner: {{ remote_user }}
|
||||||
group: hybris
|
group: {{ remote_user }}
|
||||||
with_items: "{{ kubernetes }}"
|
with_items: "{{ kubernetes }}"
|
||||||
|
|
||||||
- name: create cloud-init config
|
- name: create cloud-init config
|
||||||
template:
|
template:
|
||||||
src: "roles/terraform/files/cloud-init.cfg.j2"
|
src: "roles/terraform/files/cloud-init.cfg.j2"
|
||||||
dest: "/home/hybris/terraform/{{ item.hostname }}.cloud_init.cfg"
|
dest: "/home/{{ remote_user }}/terraform/{{ item.hostname }}.cloud_init.cfg"
|
||||||
owner: hybris
|
owner: {{ remote_user }}
|
||||||
group: hybris
|
group: {{ remote_user }}
|
||||||
with_items: "{{ kubernetes }}"
|
with_items: "{{ kubernetes }}"
|
||||||
|
|
||||||
- name: create libvirt_provider config
|
- name: create libvirt_provider config
|
||||||
copy:
|
copy:
|
||||||
src: roles/terraform/files/libvirt_provider.tf
|
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
|
- name: delete statefile if it exists
|
||||||
file:
|
file:
|
||||||
path: /home/hybris/terraform/terraform.tfstate
|
path: /home/{{ remote_user }}/terraform/terraform.tfstate
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: initialize terraform
|
- name: initialize terraform
|
||||||
shell: terraform init
|
shell: terraform init
|
||||||
args:
|
args:
|
||||||
chdir: /home/hybris/terraform
|
chdir: /home/{{ remote_user }}/terraform
|
||||||
|
|
||||||
- name: plan terraform
|
- name: plan terraform
|
||||||
shell: terraform plan -out=cloud-init-plan
|
shell: terraform plan -out=cloud-init-plan
|
||||||
args:
|
args:
|
||||||
chdir: /home/hybris/terraform
|
chdir: /home/{{ remote_user }}/terraform
|
||||||
|
|
||||||
- name: apply terraform
|
- name: apply terraform
|
||||||
shell: terraform apply "cloud-init-plan"
|
shell: terraform apply "cloud-init-plan"
|
||||||
args:
|
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 ####
|
#### KERNEL TASKS ####
|
||||||
######################
|
######################
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: get rid of inline http_proxy and fetch repo with the yum-repository ansible module
|
||||||
- name: import elrepo gpg key
|
- 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
|
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
|
- name: add docker-ce yum repository
|
||||||
shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||||
|
|
||||||
|
|
||||||
- name: copy kubernetes repo config
|
- name: copy kubernetes repo config
|
||||||
copy:
|
copy:
|
||||||
src: /Users/hybris/dev/k8s-ansible/files/kubernetes.repo
|
src: ../files/kubernetes.repo
|
||||||
dest: /etc/yum.repos.d/kubernetes.repo
|
dest: /etc/yum.repos.d/kubernetes.repo
|
||||||
|
|
||||||
- name: install packages
|
- name: install packages
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#cloud-config
|
#cloud-config
|
||||||
users:
|
users:
|
||||||
- name: hybris
|
- name: {{ remote_user }}
|
||||||
lock-passwd: false
|
lock-passwd: false
|
||||||
passwd: $1$tG6Uv4$BPCIRF6RFuLrJ.lQO1GB8.
|
passwd: $1$tG6Uv4$BPCIRF6RFuLrJ.lQO1GB8.
|
||||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
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)}')
|
# inet6_addr=$(ip a s | grep "inet6 2001:470:6d:22c:" | awk '{print substr($2,0)}')
|
||||||
sudo hostnamectl set-hostname {{ item.hostname }}
|
sudo hostnamectl set-hostname {{ item.hostname }}
|
||||||
sudo ip -6 addr add {{ item.ipv6 }}/64 dev eth0
|
sudo ip -6 addr add {{ item.ipv6 }}/64 dev eth0
|
||||||
sudo chown -R hybris:hybris /home/hybris
|
sudo chown -R {{ remote_user }}:{{ remote_user }} /home/{{ remote_user }}
|
||||||
path: /home/hybris/cloud-init.sh
|
path: /home/{{ remote_user }}/cloud-init.sh
|
||||||
owner: hybris:hybris
|
owner: {{ remote_user }}:{{ remote_user }}
|
||||||
permissions: '0744'
|
permissions: '0744'
|
||||||
runcmd:
|
runcmd:
|
||||||
- [ '/home/hybris/cloud-init.sh' ]
|
- [ '/home/{{ remote_user }}/cloud-init.sh' ]
|
||||||
|
@ -36,32 +36,32 @@
|
|||||||
- name: go install terraform-provider-libvirt
|
- name: go install terraform-provider-libvirt
|
||||||
shell: /usr/local/go/bin/go install
|
shell: /usr/local/go/bin/go install
|
||||||
args:
|
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
|
- name: create terraform config directory
|
||||||
file:
|
file:
|
||||||
path: /home/hybris/.terraform.d/
|
path: /home/{{ remote_user }}/.terraform.d/
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: create terraform plugin directory
|
- name: create terraform plugin directory
|
||||||
file:
|
file:
|
||||||
path: /home/hybris/.terraform.d/plugins
|
path: /home/{{ remote_user }}/.terraform.d/plugins
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: install terraform-provider-libvirt
|
- name: install terraform-provider-libvirt
|
||||||
copy:
|
copy:
|
||||||
src: /home/hybris/go/bin/terraform-provider-libvirt
|
src: /home/{{ remote_user }}/go/bin/terraform-provider-libvirt
|
||||||
dest: /home/hybris/.terraform.d/plugins/terraform-provider-libvirt
|
dest: /home/{{ remote_user }}/.terraform.d/plugins/terraform-provider-libvirt
|
||||||
mode: 0777
|
mode: 0777
|
||||||
owner: hybris
|
owner: {{ remote_user }}
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
|
|
||||||
- name: delete terraform directory
|
- name: delete terraform directory
|
||||||
file:
|
file:
|
||||||
path: /home/hybris/terraform
|
path: /home/{{ remote_user }}/terraform
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: create terraform directory
|
- name: create terraform directory
|
||||||
file:
|
file:
|
||||||
path: /home/hybris/terraform
|
path: /home/{{ remote_user }}/terraform
|
||||||
state: directory
|
state: directory
|
||||||
|
Loading…
Reference in New Issue
Block a user