replace hard-coded usernames with remote_user variable

This commit is contained in:
hybris 2019-01-22 13:22:12 +01:00
parent ee4a13c926
commit ad8e3cc155
5 changed files with 36 additions and 25 deletions

View 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

View file

@ -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

View file

@ -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' ]

View file

@ -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