Fix variabilization.

This commit is contained in:
yohan 2024-10-22 23:56:16 +02:00
parent f905d1a378
commit 3ecd838336
3 changed files with 17 additions and 7 deletions

View File

@ -48,7 +48,7 @@
- always
- name: Remove old SSH host key
command: ssh-keygen -f "/home/{{ LINUX_USERNAME }}/.ssh/known_hosts" -R "{{ item }}"
command: ssh-keygen -f "{{ ansible_user_dir }}/.ssh/known_hosts" -R "{{ item }}"
changed_when: false
with_items:
- "{{ target_name }}"
@ -109,9 +109,15 @@
- common
- always
- name: Gather facts
ansible.builtin.setup:
tags:
- common
- always
- name: set remote workdir path
ansible.builtin.set_fact:
remote_workdir: "/home/{{ ansible_user }}/{{ ANSIBLE_WORKDIR }}"
remote_workdir: "{{ ansible_user_dir }}/{{ ANSIBLE_WORKDIR }}"
tags:
- common
- always

View File

@ -261,17 +261,20 @@
set_fact:
ansible_user: "{{ LINUX_USERNAME }}"
- name: Gather facts
ansible.builtin.setup:
# Those will deploy SSH keys found on the Ansible controller
- name: Deploy SSH private key
copy:
src: "{{ PRIVATE_KEY_FILE }}"
dest: "/home/{{ LINUX_USERNAME }}/.ssh/"
dest: "/{{ ansible_user_dir }}/.ssh/"
mode: 0600
- name: Deploy SSH public key
copy:
src: "{{ PUBLIC_KEY_FILE }}"
dest: "/home/{{ LINUX_USERNAME }}/.ssh/"
dest: "/{{ ansible_user_dir }}/.ssh/"
mode: 0640
- name: Configure VIM
@ -338,12 +341,12 @@
- name: user.email
value: "{{ git_email }}"
- name: Create /home/{{ LINUX_USERNAME }}/.bashrc.d directory
- name: Create {{ ansible_user_dir }}/.bashrc.d directory
ansible.builtin.file:
path: "/home/{{ LINUX_USERNAME }}/.bashrc.d"
path: "{{ ansible_user_dir }}/.bashrc.d"
state: directory
- name: deploy .bashrc.d/tmux
ansible.builtin.copy:
src: tmux
dest: "/home/{{ LINUX_USERNAME }}/.bashrc.d/tmux"
dest: "{{ ansible_user_dir }}/.bashrc.d/tmux"

View File

@ -10,6 +10,7 @@ SWIFT_REGIONNAME: "GRA"
LINUX_USERNAME: "yohan"
# Path of SSH key pair on Ansible controller
PRIVATE_KEY_FILE: "/home/{{ LINUX_USERNAME }}/.ssh/id_rsa"
PUBLIC_KEY_FILE: "/home/{{ LINUX_USERNAME }}/.ssh/id_rsa.pub"