Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.97 KB

temp_activity.md

File metadata and controls

64 lines (47 loc) · 1.97 KB

Busted Playbook Challenge!

Good morning! To get the blood moving today we are going to FIX a BROKEN playbook! This is what the playbook is SUPPOSED to do:

  • access localhost (our bchd VM)
  • create a new directory using the file module
  • create a new file inside that directory containing the word "Success!" using the copy module

Debugging tip: run the playbook, see what error occurs. Then, focus on ONLY fixing that error. Then run again! Try not to introduce more errors as you go, focus on one thing at a time.

Use vim to create a playbook file of your choosing and enter the following.

student@bchd:~$ cd ~/mycode

student@bchd:~/mycode$ vim ~/mycode/tuesday_warmup.yml

---
- name: Tuesday Challenge
  hosts: localhost
  connection: network_cli
  gather_facts: no

  tasks:
   -name: creating a file
     copy:
        dest: challenge/challengefile.txt
       contents: "Success!"
       
   - name: create a directory
     file: 
       dest: challenge
       state: directry

student@bchd:~/mycode$ ansible-playbook ~/mycode/tuesday-warmup.yml

Click here for the solution!
---
- name: Tuesday Challenge
  hosts: localhost
  connection: local             # WRONG CONNECTION- "local," not network_cli
  gather_facts: no

  tasks:                        # WRONG TASK ORDER- make dir first, then file
   - name: create a directory
     file: 
       dest: challenge
       state: directory         # TYPO- directory, not directry
 
   - name: creating a file      
     copy:                                 # INDENTATION
       dest: challenge/challengefile.txt   # ERRORS ON THESE
       content: "Success!"                 # THREE LINES... also it is "content" NOT "contents"