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 - always
- name: Remove old SSH host key - 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 changed_when: false
with_items: with_items:
- "{{ target_name }}" - "{{ target_name }}"
@ -109,9 +109,15 @@
- common - common
- always - always
- name: Gather facts
ansible.builtin.setup:
tags:
- common
- always
- name: set remote workdir path - name: set remote workdir path
ansible.builtin.set_fact: ansible.builtin.set_fact:
remote_workdir: "/home/{{ ansible_user }}/{{ ANSIBLE_WORKDIR }}" remote_workdir: "{{ ansible_user_dir }}/{{ ANSIBLE_WORKDIR }}"
tags: tags:
- common - common
- always - always

View File

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