You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where the mode, owner, and group are hard-coded. These could easily conflict with other tasks/playbooks that interact with this file or directory. It would be good to have config variables like xyz_mode = 0755 and xyz_owner = someowner such that the above task could be rewritten:
m_paths:
data:
path: "/opt/data-meza"owner: meza-ansiblegroup: wheelmode: "0775"servers: alluploads:
path: "/opt/data-meza/uploads"better_path: "{{ m_paths.data.path }}/uploads"# if possible to do something like this (prob not)owner: apachegroup: apachemode: "0775"servers: app-servers
Then could setup paths like:
- name: Setup pathsfile:
path: "{{ item.path }}"state: directorymode: "{{ item.mode }}"owner: "{{ item.owner }}"group: "{{ item.group }}"with_items: "{{ m_paths }}"when: item.servers == "all" or inventory_hostname _is in any of item.servers_ # what if item.servers is a list?
At present many Ansible tasks look like:
Where the mode, owner, and group are hard-coded. These could easily conflict with other tasks/playbooks that interact with this file or directory. It would be good to have config variables like
xyz_mode = 0755
andxyz_owner = someowner
such that the above task could be rewritten:Perhaps this could be taken a step further, such that the configuration variable could be written as an object that looks like:
And the task could be rewritten:
That may be taking it too far, though.
The text was updated successfully, but these errors were encountered: