2016-04-15 9 views
18

मेरे पास मेरे सर्वर पर एक उत्तरदायी 2.1.0 है, जहां मैं वानर और पीसी पर भी तैनाती करता हूं। भूमिका "तैनात" है:बनने/बनने वाले का उपयोग कर उत्तर 2.1.0 अस्थायी फ़ाइल पर अनुमतियां सेट करने में विफल रहता है

- name: upload code 
    become: true 
    become_user: www-data 
    git: [email protected]:****.git 
    dest=/var/www/main 
    key_file=/var/www/.ssh/id_rsa 
    accept_hostkey=true 
    update=yes 
    force=yes 
register: fresh_code 
notify: restart php-fpm 
tags: fresh_code 

ansible 2.1.0 के साथ इस मामले में मैं एक त्रुटि मिलती है:

fatal: [default]: FAILED! => {"failed": true, "msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user. For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"} 

यह ansible 2.0.1.0 जो मैं अपने पीसी पर उपयोग करते हैं, सब है सामान्य रूप से - फ़ोल्डर/var/www/मालिक और समूह के साथ फ़ोल्डर मुख्य है www-data

यदि मैं केवल be_user का उपयोग करता हूं: www-data और यदि मैं be_method का उपयोग करता हूं: beud_user के साथ sudo: www-data - मुझे एक ही त्रुटि मिली

इसे हल करने के लिए क्या करने की आवश्यकता है?

उत्तर

14

समस्या यह है कि www-data उसी फ़ाइल तक नहीं पहुंच सकता है जो आपके डिफ़ॉल्ट गैर रूट रूट उपयोगकर्ता द्वारा बनाई गई है जिसे आप मशीन से कनेक्ट करने के लिए उपयोग करते हैं। इसके अलावा त्रुटि संदेश स्पष्ट रूप से ansible's documentation पर इंगित करता है जो बताता है कि उत्तर 2.0 या उससे नीचे के उन्नयन के दौरान आपको इस समस्या को ठीक करने के लिए क्या विकल्प हैं।

वे तीन तरीके ठीक से इस मुद्दे को ठीक करने के लिए सुझाव:

  • Use pipelining. When pipelining is enabled, Ansible doesn’t save the module to a temporary file on the client. Instead it pipes the module to the remote python interpreter’s stdin. Pipelining does not work for non-python modules.
  • Install filesystem acl support on the managed host. If the temporary directory on the remote host is mounted with filesystem acls enabled and the setfacl tool is in the remote PATH then Ansible will use filesystem acls to share the module file with the second unprivileged instead of having to make the file readable by everyone.
  • Don’t perform an action on the remote machine by becoming an unprivileged user. Temporary files are protected by UNIX file permissions when you become root or do not use become. In Ansible 2.1 and above, UNIX file permissions are also secure if you make the connection to the managed machine as root and then use become to an unprivileged account.

या यदि आप इन सुधारों से कोई भी कार्य नहीं कर सकते, तो आप ansible थोड़ा में चलाने के लिए और अधिक असुरक्षित रास्ता (जो लग रहा था मजबूर कर सकते हैं ansible 2 और नीचे) में डिफ़ॉल्ट है, जो भी आपकी समस्या का समाधान करना चाहिए, लेकिन अंतर्निहित सुरक्षा जोखिम को ठीक नहीं होगा:

If you can’t make any of the changes above to resolve the problem and you decide that the machine you’re running on is secure enough for the modules you want to run there to be world readable you can turn on allow_world_readable_tmpfiles in the ansible.cfg file. Setting allow_world_readable_tmpfiles will change this from an error into a warning and allow the task to run as it did prior to 2.1.

+3

पुनरावृत्ति के लिए धन्यवाद। मेरे लिए दूसरे जवाब में मदद करें। मैंने एसीएल-टूल्स इंस्टॉल किए हैं और समस्या हल हो गई है। प्लेबुक में मैं 'बन गया: सच बनने वाला: www-data' का उपयोग करता हूं और सभी अच्छी तरह से चल रहे हैं – DeamonMV

+2

डेबियन सर्वर (विकल्प 2) पर' एसीएल 'मॉड्यूल स्थापित करना मेरे लिए सबसे आसान विकल्प था, और यह भी काम करता है अगर आपने "छोड़ दिया है सर्वर पर अस्थायी फ़ाइलें "डीबगिंग के लिए सक्षम। मैंने उत्तरदायी पाइपलाइनिंग काम करने के लिए छोड़ दिया (ओएस एक्स 10.11 क्लाइंट, डेबियन 7 सर्वर, विभिन्न कॉन्फ़िगरेशन फ़ाइल परिवर्तनों की कोशिश की लेकिन कुछ भी काम नहीं किया)। मैंने यह भी पाया कि "रूट के रूप में कनेक्ट करें" विकल्प का उपयोग एक असंबंधित बग में चलाया गया जहां अधिकांश प्लेबुक चुपचाप छोड़ दिया गया था। – RichVel

+0

यदि आपको "रूट के रूप में कनेक्ट करें" तकनीक का उपयोग करते समय "हार्ड-टू-पासवर्ड" तकनीक (विकल्प 3) के साथ इन कठोर-से-Google लक्षण प्राप्त होते हैं, तो मूल कारण यह समस्या है - बस 'acl' मॉड्यूल को इंस्टॉल करें) उन्हें ठीक करें: "प्लेबुक सूडो पासवर्ड के लिए पूछता है और इसे सूडो में उपयोग करता है (यदि गलत टाइप किया गया है तो आपको पासवर्ड त्रुटि मिलती है) लेकिन फिर [सेटअप] निहित कार्य (जो सफल होने लगती है) के बाद त्रुटि के बिना बाहर निकलती है"। एक उत्तर 2.1.0 बग की तरह लगता है। – RichVel

35

Debian/Ubuntu आप पहली बार दूरस्थ होस्ट पर acl पैकेज स्थापित करके इस हल कर सकते हैं पर, इस उत्तरदायी कार्य के साथ:

- name: install setfacl support 
    become: yes 
    apt: pkg=acl 

redhat/centos के साथ भी यही बात - दूरस्थ होस्ट पर acl पैकेज स्थापित:

- name: install setfacl support 
    become: yes 
    yum: name=acl 
+0

क्या इसे 'fstab' या रीबूट में परिवर्तन की आवश्यकता है? – meshy

+0

मेरे मामले में रीबूट की आवश्यकता नहीं थी। –

संबंधित मुद्दे

 संबंधित मुद्दे