Hello,
I would like to clarify some details related to the task
Creating Soft Links Using Ansible
According to the task 4 steps should have done to finish the task:
-
create src directory for the empty file
-
create destination directory for the symbolik link
-
create an empty file with a proper permissions
in the directory that was created on step [1] -
create symbolik link from the file created on step [3] to
the destination directory created on step [2]
The same operations should be repeated for all application servers (1,2 and 3)
The task finished without any errors.
After ssh I checked the presence of the file and the symlink on the application server1
and found both the file and symlink, however I got the error message:
it seems like you haven’t create symbolic link to ‘/var/www/html’ properly on App Server 1
Please see the output of the /opt/security/ folder on stapp01
[tony@stapp01 ~]$ ls -la /opt/security/
total 8
drwxr-xr-x 2 root root 4096 Jul 15 11:30 .
drwxr-xr-x 1 root root 4096 Jul 15 11:27 …
-rw-r–r-- 1 tony tony 0 Jul 15 11:30 blog.txt
Please see the output of the /var/www/hmtl/ folder on stapp01
[tony@stapp01 ~]$ ls -la /var/www/html/
total 8
drwxr-xr-x 2 root root 4096 Jul 15 11:30 .
drwxr-xr-x 3 root root 4096 Jul 15 11:30 …
lrwxrwxrwx 1 root root 22 Jul 15 11:30 blog.txt → /opt/security/blog.txt
Below is ansible playbook that was used to accomplish this task:
hosts: all
become: yes
gather_facts: yes
vars:src_path: “/opt/security”
dst_path: “/var/www/html”
file1: “blog.txt”
file2: “story.txt”
file3: “media.txt”tasks:
block:
name: “Create src directory {{ src_path }}”
file:
path: “{{ src_path }}”
state: directoryname: “Create dst directory {{ dst_path }}”
file:
path: “{{ dst_path }}”
state: directoryname: “Create empty file {{ src_path }}/{{ file1 }}”
file:
path: “{{ src_path }}/{{ file1 }}”
state: touch
owner: tony
group: tonyname: “Create symlink {{ src_path }}/{{ file1 }} {{ dst_path }}/{{ file1 }}”
file:
src: “{{ src_path }}/{{ file1 }}”
dest: “{{ dst_path }}/{{ file1 }}”
state: linkwhen: inventory_hostname == “stapp01”
block:
name: “Create src directory {{ src_path }}”
file:
path: “{{ src_path }}”
state: directoryname: “Create dst directory {{ dst_path }}”
file:
path: “{{ dst_path }}”
state: directoryname: “Create empty file {{ src_path }}/{{ file2 }}”
file:
path: “{{ src_path }}/{{ file2 }}”
state: touch
owner: steve
group: stevename: “Create symlink {{ src_path }}/{{ file2 }} {{ dst_path }}/{{ file2 }}”
file:
src: “{{ src_path }}/{{ file2 }}”
dest: “{{ dst_path }}/{{ file2 }}”
state: linkwhen: inventory_hostname == “stapp02”
block:
name: “Create src directory {{ src_path }}”
file:
path: “{{ src_path }}”
state: directoryname: “Create dst directory {{ dst_path }}”
file:
path: “{{ dst_path }}”
state: directoryname: “Create empty file {{ src_path }}/{{ file3 }}”
file:
path: “{{ src_path }}/{{ file3 }}”
state: touch
owner: banner
group: bannername: “Create symlink {{ src_path }}/{{ file3 }} {{ dst_path }}/{{ file3 }}”
file:
src: “{{ src_path }}/{{ file3 }}”
dest: “{{ dst_path }}/{{ file3 }}”
state: link
when: inventory_hostname == “stapp03”
Could you please advise on what might be wrong here?
Could it be that validation system for the AppServer 1 does not work as expected?
Thank you.
Best regards,
Alex