Monday, March 12, 2018

Ansible "mapping values are not allowed in this context" Error

Symptom:

 When we try to put 2 logic commands into 1 element, like find and copy, we hit below error
The offending line appears to be:

   - name: copy env profile script to the target
      - find:
            ^ here
exception type: <class 'yaml.scanner.ScannerError'>
exception: mapping values are not allowed in this context


The part of related yaml file are
tasks:
   - name: find and copy  env profile scripts
      - find: 
              paths: /u01/app/ansible/repository
              patterns: 'apex-ext-stg'
        register: file_to_copy
      - copy: src={{ item.path }} dest=/tmp   mode=0775
        with_items: "{{ files_to_copy.files }}" 

 Reason:

"find" and "copy" are 2 different tasks. we need to use block to group them together , or we level it up with "- name"

Solution:

- name: find and copy  env profile scripts
  block:
        - find:
               paths: /u01/app/ansible/repository
               patterns: 'test-ext-stg'
          register: file_to_copy
        - copy: src={{ item.path }} dest=/tmp  mode=0775
          with_items: "{{ files_to_copy.files }}"

or

- name: find and copy  env profile scripts part1
  find:
               paths: /u01/app/ansible/repository
               patterns: 'test-ext-stg'
  register: file_to_copy
- name: find and copy  env profile scripts part2
  copy: src={{ item.path }} dest=/tmp  mode=0775
  with_items: "{{ files_to_copy.files }}"



22 comments:

radha said...

Code works. Keep updating Devops Online Course

Sai Elakiyaa said...

Great inspiration today!!! thanks for your blog.

ReactJS Training in Chennai
Java Training in Chennai
German Classes in Chennai
CCNA Training in Chennai
Best Spoken English Institute in Chennai
Spoken English Classes in Chennai

Sai Elakiyaa said...



Worth for my valuable time, I am very much satisfied with your blog. Thanks for sharing.

AngularJS Training in Chennai
AWS Training in Chennai
DevOps Training in Chennai
Spoken English Classes in Chennai
Spoken English Class in Chennai

Senthil said...

I appreciate your blog writing about that specific topics.I am following your blog post regularly to get more updates
DevOps Training in Anna nagar
Devops Training in chennai
AWS Training in Anna nagar
AWS Course in Anna nagar
Data Science Course in anna nagar
Data Science Training in anna nagar
Blue Prism Training in Anna nagar
RPA Training in Anna nagar

jenifer irene said...

Very nice blog, Thank you for providing good information.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
aviation institute in Chennai
cabin crew training in Chennai
diploma in airport management course in Chennai
airport ground staff training courses in Chennai

sandeep saxena said...

I like to learn a piece of new information about technology. Im really like your post. Good job.
Struts Training in Chennai
Best Struts Training institute in Chennai
Best Struts Training in Chennai
struts Training in Porur
Wordpress Training in Chennai
Wordpress Training
Spring Training in Chennai
Hibernate Training in Chennai

kavithasathish said...

Great information you have been shared and it will be useful to everyone.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
German Classes in Chennai
TOEFL Coaching in Chennai
IELTS Coaching in Chennai
spanish language in chennai
Spoken English Classes in OMR
Spoken English Classes in Porur

priya rajesh said...

Excellent blog with unique content, thanks a lot for sharing this. I love to learn more about this topic.
Data Science Training in Chennai
Data Science Certification in Chennai
R Programming Training in Chennai
R analytics Training in Chennai
Machine Learning Training in Chennai
Machine Learning course
Data Science Training in Velachery
Data Science Course in Chennai

priyanka usha said...

Great job done. Excellent post for the freshers. Keep updating it.
TOEFL Coaching in Chennai
TOEFL Coaching Centres in Chennai
German Courses in Chennai
Best IELTS Coaching in Chennai
learn Japanese in Chennai
spanish language classes in chennai
TOEFL Coaching in Anna Nagar
TOEFL Coaching in Tnagar
Spoken English Class in Anna Nagar
spoken english course in anna nagar

cynthiawilliams said...

Hearty thanks to you admin, your blog is awesome and helpful. Keep your blog with latest information.
RPA Training in Chennai
Robotics Process Automation Training in Chennai
Blue Prism Training in Chennai
Blue Prism Training
Blue Prism Training in Anna Nagar
UiPath Training in Chennai
Data Science Course in Chennai
RPA Training in Anna Nagar

Deva Dev said...

Nice Blog thanks for sharing this information...
RPA training in bellandur
RPA training near bellandur
RPA courses in bellandur
RPA courses near bellandur
RPA classes in bellandur
RPA classes near bellandur
AWS training in bellandur
AWS training near bellandur
AWS courses in bellandur
AWS courses near bellandur
AWS classes in bellandur
AWS classes near bellandur





Ajish said...

Nice Post! Thank you for sharing very good post, it was so Nice to read and useful to improve my knowledge as updated one, keep blogging.
ASW training in Electronic City

Never Ending Footsteps said...

data science course bangalore is the best data science course

chandhran said...

It is an excellent blog. Your post is very good and unique.
DevOps Training in Bangalore
DevOps Training in Marathahalli
Best DevOps Training in Marathahalli
DevOps Training Institutes in Marathahalli
DevOps Institute in Marathahalli
DevOps certification in Chennai
DevOps course in Chennai
Best DevOps Training in Chennai
DOT NET Training in Bangalore
PHP Training in Bangalore

Riya Raj said...

It's remarkable. The way you describe the information is awesome. This will really help me out. Thanks for sharing.
VMware Training in Chennai
VMware Course in Chennai
Vmware Training center in Chennai
Vmware Learning
VMware Training
Vmware cloud certification

datasciencecourse said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!

data science course

priyash said...

wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
Data Science Course

datasciencecourse said...

I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

Correlation vs Covariance

priyash said...

Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
Correlation vs Covariance
Simple linear regression

priyash said...

Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
Correlation vs Covariance
Simple Linear Regression
data science interview questions
KNN Algorithm

priyanka said...

Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
Simple Linear Regression
Correlation vs covariance
data science interview questions
KNN Algorithm
Logistic Regression explained

hrithiksai said...

Very nice blogs!!! i have to learning for lot of information for this sites…Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing, data science online training