Task which throwing error: name: Create Prometheus install and config directory
become: true. <------ does not work file: path: "{{ item }}" state: directory mode: 0755 owner: "{{user}}" group: "{{group}}" loop: - "{{ jmxexporter_jar_path | dirname }}" - "{{ jmxexporter_config_path }}" If i put become: true at role playbook it works but i dont want to give blanket become: true hence i was trying to do at task level. vim prometheusjmxrole.yml name: Deploy jmx_exporter hosts: all become: true. <---------------- works fine if we set it here but i dont want it in this way. tasks: - name: Importing jmx prometheus role import_role: name: prometheusjmx On Tuesday, May 14, 2024 at 2:08:14 PM UTC+5:30 Sameer Modak wrote: > Hello team, > > I am running a role like below despite putting become true for install > task i get error. However if run with -b it works. > > Getting error while running this , > > ansible-playbook prometheusjmxrole.yml -i ../inventory/staging.yaml > > The full traceback is: > > WARNING: The below traceback may *not* be related to the actual failure. > > File > "/tmp/ansible_file_payload_CA4MQM/ansible_file_payload.zip/ansible/module_utils/basic.py", > > line 841, in set_owner_if_different > > os.lchown(b_path, uid, -1) > > failed: [10.xx.xx.xxx] (item=/etc/jmx_prometheus/) => { > > "ansible_loop_var": "item", > > "changed": false, > > "gid": 0, > > "group": "root", > > "invocation": { > > "module_args": { > > "_diff_peek": null, > > "_original_basename": null, > > "access_time": null, > > "access_time_format": "%Y%m%d%H%M.%S", > > "attributes": null, > > "follow": true, > > "force": false, > > "group": "confluent", > > "mode": 493, > > "modification_time": null, > > "modification_time_format": "%Y%m%d%H%M.%S", > > "owner": "cp-kafka", > > "path": "/etc/jmx_prometheus/", > > "recurse": false, > > "selevel": null, > > "serole": null, > > "setype": null, > > "seuser": null, > > "src": null, > > "state": "directory", > > "unsafe_writes": false > > } > > }, > > "item": "/etc/jmx_prometheus/", > > "mode": "0755", > > "msg": "chown failed: [Errno 1] Operation not permitted: > '/etc/jmx_prometheus/'", > > "owner": "root", > > "path": "/etc/jmx_prometheus/", > > "secontext": "unconfined_u:object_r:etc_t:s0", > > "size": 4096, > > "state": "directory", > > "uid": 0 > > ============== > > Working fine, > > ansible-playbook prometheusjmxrole.yml -i ../inventory/staging.yaml -b > > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/49482827-c301-4366-92af-50a02f68c761n%40googlegroups.com.