Skip to content

Instantly share code, notes, and snippets.

@AnneTheAgile
Last active August 29, 2015 14:05
Show Gist options
  • Save AnneTheAgile/7a26c63b134c3b1214b6 to your computer and use it in GitHub Desktop.
Save AnneTheAgile/7a26c63b134c3b1214b6 to your computer and use it in GitHub Desktop.
talk-battle-config-gist
---
cache_dir: ~/Library/Caches/battleschool
# Originally, SpencerGibb: https://dl.dropboxusercontent.com/u/622216/battleschool/config.yml
# 2014-08-15Fri Change to AnneTheAgile
sources:
# local:
# - playbook.yml
url:
- name: playbook.yml
url: https://gist.githubusercontent.com/AnneTheAgile/28db99bd15718d2d1fe7/raw/24c8adff20191cbc27028128a9a3613711add9b1/talk-battle-playbook.yml
# https://www.dropbox.com/s/wcqanoxy1cg2o1c/playbook.yml
# was; url: https://www.dropbox.com/s/p55do4578af9q8f/playbook.yml
# was spencergibb: url: https://db.tt/VcyI9dvr
git:
- name: 'osx'
repo: 'https://github.com/spencergibb/ansible-osx'
playbooks:
- homebrew.yml #must come before any use of homebrew module
#- macports.yml #must come before any use of macports module
- vagrant.yml
- virtualbox.yml
- alfred.yml
- chrome-beta.yml
- dropbox.yml
#- intellij-idea-ultimate13.yml
- java7.yml
- java6.yml
- iterm2.yml
- macvim.yml
#- better-touch-tool.yml
#- adium.yml
#- github.yml
#- gitx.yml
#- libreoffice.yml
#- sequel-pro.yml
#- skype.yml
#- truecrypt.yml
#- usb-overdrive.yml
#- xtra-finder.yml
@AnneTheAgile
Copy link
Author

Hunt for apps.

Seek via ObjectiveC code.
http://stackoverflow.com/questions/25290144/code-to-check-if-an-external-app-exists-without-breaking-the-sandbox

Bash instead of Apple App Store.
List of methods, including for brew;
http://apple.stackexchange.com/questions/42353/can-mac-app-store-installs-upgrades-be-automated

LIST of App Store Apps might like to have
1.Xcode
https://itunes.apple.com/us/app/xcode/id497799835?mt=12
Category: Developer Tools
Updated: Apr 10, 2014
Version: 5.1.1
Size: 2.18 GB
Info page = https://developer.apple.com/xcode/

@AnneTheAgile
Copy link
Author

1.[] ; X.How can i check the file existence in ansible - Stack Overflow
http://stackoverflow.com/questions/22469880/how-can-i-check-the-file-existence-in-ansible

# Ansible 1.3+
- local_action: stat path={{secrets_dir}}/secrets.yml
  register: secrets_exist

- fail: msg="Production credentials not found"
  when: secrets_exist.stat.exists == False

# OR
# Register a variable if the file exists, then use a when condition to execute the command on the condition that the file doesn't already exist:
- command: /usr/bin/test -e {{project_root}}/solr/solr-4.7.0.zip
  register: solr_zip
  ignore_errors: True
- name: Download Solr
  shell: chdir={{project_root}}/solr /usr/bin/wget http://mirror.mel.bkb.net.au/pub/apache/lucene/solr/4.7.0/solr-4.7.0.zip
  when: solr_zip|failed

# OR
#1.Read Docs; 
# 1a.Many modules are already aware of the result and will be skipped if its already there, like file or geturl. 
# 1b.Others like command have a creates option, which will skip this command if that file already exists (or doesn't exist, if you use the removes option).
#2.If no luck, the stats module avoids "red errors but ignored" in the output.
- name: Check MySQL data directory existence
  stat: path=/var/lib/mysql-slave
  register: mysql_slave_data_dir

- name: Stop MySQL master to copy data directory
  service: name=mysql state=stopped
  sudo: yes 
  when: not mysql_slave_data_dir.stat.exists

To Download a file.

# To also save state of download use a registered variable event, get_solr; 

---
- hosts        : all
  gather_facts : no
  tasks:
   - get_url:
       url="http://mirror.mel.bkb.net.au/pub/apache/lucene/solr/4.7.0/solr-4.7.0.zip"
       dest="{{project_root}}"
     register: get_solr

   - debug: 
       msg="solr was downloaded"
     when: get_solr|changed

@AnneTheAgile
Copy link
Author

Pycon UK talk that recommended Ansible on Ubuntu, showed a bit of Flask.
1.[] ; X.Python for Configuration Management (with Ansible) (My PYCON UK 2013 Talk) - Virtual Vitriol
http://www.insom.me.uk/post/pycon-talk.html
published Friday, 20 September 2013
https://speakerdeck.com/insom/python-for-configuration-management-with-ansible
https://github.com/insom/ansible-example

@AnneTheAgile
Copy link
Author

CIB, Docker
1.[] ; X.The Why and How of Ansible and Docker - The Changelog
http://thechangelog.com/ansible-docker/
The Why and How of Ansible and Docker - The Changelog
Infrastructure as code tedious; Jan. 2014 talk [2]

2.[] ; X.Ansible & Docker - The Path to Continuous Delivery - Part 1 // Speaker Deck
https://speakerdeck.com/gerhardlazu/ansible-and-docker-the-path-to-continuous-delivery-part-1
Ansible & Docker - The Path to Continuous Delivery - Part 1 // Speaker Deck
Chat notify when CID done, Git Hook
Environments: Need many: Qa, Prod, Dev, Staging, Beta, Integration, etc.
Master=prod; DNS = [fqdn]
Branch=non-prod ; DNS = [branch].[fqdn]
Container (!= VM) and (== Process = SRP, Single Responsibility Principle)
ex.CI
bin/ap terrabox.yml dohosts -l docker-ams2 -e 'app_branch=gem-updates'
Dependent container:
https://speakerd.s3.amazonaws.com/presentations/846d6f106aa10131a94d1ece10ede835/Ansible___Docker_-_The_Path_to_Continuous_Delivery_-_Docker_Blog_Post.pdf

General Ansible
1.[] ; X. Solving IT automation simply, with Ansible - YouTube
http://www.youtube.com/watch?v=jje38YBGVt4
Solving IT automation simply, with Ansible - YouTube
Streamed live on Apr 17, 2014
How do you manage all of the servers, applications, at scale? One great solution is +Ansible.
http://www.youtube.com/watch?feature=player_detailpage&v=jje38YBGVt4#t=654
DeHaan> Problem is all the agents, are they set up ok?
@15> Don't deploy each 2 months where you forget [the details]

More UK Great intro
1.[]Jan. 2014 ; X.Ansible_Introduction - access
https://indico.uknof.org.uk/getFile.py/access?contribId=0&resId=0&materialId=slides&confId=29
Ansible_Introduction - access
2.[] ; X.UKNOF27 (21 January 2014)
https://indico.uknof.org.uk/conferenceOtherViews.py?view=standard&confId=29
3.[] ; X. UKNOF27 - Ansible for configuration management - YouTube
http://www.youtube.com/watch?v=FMfh2SXlbEo
Published on Jan 28, 2014
Speaker: Mr. Anand Buddhdev (RIPE NCC)

# Limiting runs to some hosts ; Use the -l (lowercase L) option
$ ansible-playbook httpd.yml -l aws1

# Jinja Variables and run multi
- hosts: dns_servers
vars:
nsd_procs: 8
zones: [ in-addr.arpa, ip6.arpa ]
tasks:
- name: nsd config file
template: src=nsd.conf.j2 dest=/etc/nsd 

# Where File Template = nsd.conf.j2
server:
server-count: {{nsd_procs}}
identity: {{ansible_fqdn}}
{% for x in range(5) %}
ip-address: 193.0.9.{{x}}
{% endfor %}
!
{% for zone in zones %}
zone:
name: {{zone}}
request-xfr: 1.2.3.4
{% endfor %}

Best Layout

# Playbooks can become large and unreadable vs Roles are parts, eg on Galaxy
# Roles allow grouping of related tasks, files, templates, variables and handlers
# Role directory structure:
myrole/
files/{file1.conf,file2.txt}
handlers/main.yml
tasks/main.yml
templates/{file3.conf.j2,otherfile.j2}
vars/main.yml

#  two playbooks
bootstrap.yml, for bootstrapping newly installed nodes: 1.Rsync ansible; 2.Upstart check lead; 3.Upload my new SSH; 4.Manual Git push to commit those changes.
main.yml, the main workhorse with all roles defined
Log results 

"Scales from a handful of systems to hundreds" => See other tool

@AnneTheAgile
Copy link
Author

On OSX
https://devopsu.com/guides/ansible-mac-osx.html
1.Xcode for building
2.Pip
3.Pip install ansible
4.Later

$ sudo pip install ansible --upgrade
$ export ANSIBLE_HOSTS=/root/ansible_hosts
$ ansible all --inventory-file=/root/ansible_hosts -m ping
leader$ ssh-keygen -t rsa -C "name@example.org"
leader$ ssh-copy-id user@child1.dev
leader$ ansible all -m ping

Pip Search to Find from remote.
http://pip.readthedocs.org/en/latest/reference/pip_search.html
Pip List and Pip Show to get info about current machine.

@AnneTheAgile
Copy link
Author

1.SWC-style Ansible tutorial, updated days ago as of 2014-08-16Sat.
https://github.com/leucos/ansible-tuto

2.SWC NYPL 2014.08
https://github.com/swcarpentry/2014-08-06-nypl

3.SSH Keys .[] ; X.6 practices for super smooth Ansible experience by Maxim Chernyak
http://hakunin.com/six-ansible-practices

@AnneTheAgile
Copy link
Author

@AnneTheAgile
Copy link
Author

ansible macbook-playbook
https://github.com/mpereira/macbook-playbook

# Prepare machine to run the Ansible playbooks
$ ./scripts/bootstrap
...
Successfully installed paramiko PyYAML jinja2 ansible pycrypto ecdsa markupsafe
Cleaning up...

Need GUI Auth for Terminal to control ; And BUG in path for item

# Configure machine
$ ansible-playbook main.yml -i hosts


PLAY [0.0.0.0] **************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [0.0.0.0]

TASK: [ansible-download-directory | Ensure the Ansible downloads directory exists] *** 
changed: [0.0.0.0]

TASK: [ssh-directory | Ensure the user SSH directory exists] ****************** 
ok: [0.0.0.0]

TASK: [caps-lock-remapped-to-control | Remap Caps Lock to Control] ************ 
failed: [0.0.0.0] => {"changed": true, "cmd": ["osascript", "roles/caps-lock-remapped-to-control/files/remap_caps_lock_to_control.scpt"], "delta": "0:00:10.723299", "end": "2014-08-16 10:53:22.999887", "rc": 1, "start": "2014-08-16 10:53:12.276588"}
stderr: roles/caps-lock-remapped-to-control/files/remap_caps_lock_to_control.scpt:218:283: execution error: System Events got an error: osascript is not allowed assistive access. (-1728)

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/annemoroney/main.retry

0.0.0.0                    : ok=3    changed=1    unreachable=0    failed=1   

$
$ ansible-playbook main.yml -i hosts  --limit @/Users/annemoroney/main.retry

PLAY [0.0.0.0] **************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [0.0.0.0]

TASK: [ansible-download-directory | Ensure the Ansible downloads directory exists] *** 
ok: [0.0.0.0]

TASK: [ssh-directory | Ensure the user SSH directory exists] ****************** 
ok: [0.0.0.0]

TASK: [caps-lock-remapped-to-control | Remap Caps Lock to Control] ************ 
changed: [0.0.0.0]

TASK: [iterm | Download iTerm] ************************************************ 
failed: [0.0.0.0] => {"dest": "//Users/annemoroney/.ansible/downloads/iTerm2-1_0_0_20131221-nightly.zip", "failed": true, "response": "HTTP Error 404: Not Found", "state": "absent", "status_code": 404, "url": "http://www.iterm2.com/nightly/iTerm2-1_0_0_20131221-nightly.zip"}
msg: Request failed

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/annemoroney/main.retry

0.0.0.0                    : ok=4    changed=1    unreachable=0    failed=1   

Now is;
http://iterm2.com/nightly/latest
As reported moved and summarized now here;
http://iterm2.com/downloads.html

@AnneTheAgile
Copy link
Author

Bug on git checkout -b ABRANCH
http://stackoverflow.com/questions/7860751/git-fatal-unable-to-create-path-my-project-git-index-lock-file-exists

http://stackoverflow.com/questions/14127255/remove-git-index-lock-permission-denied
And use their hint to chown the container folder:

`sudo chown -R myuid:mygroup ~/src/mygitfolder 
$ git checkout -b 1-fix-iterm-new-nightly-url
Switched to a new branch '1-fix-iterm-new-nightly-url'

@AnneTheAgile
Copy link
Author

Bug due to spacing fixed by re-entry. Now failing hard-coded key?

$ nano roles/iterm/tasks/main.yml 
$ ansible-playbook main.yml -i hosts 

PLAY [0.0.0.0] **************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [0.0.0.0]

TASK: [ansible-download-directory | Ensure the Ansible downloads directory exists] *** 
ok: [0.0.0.0]

TASK: [ssh-directory | Ensure the user SSH directory exists] ****************** 
ok: [0.0.0.0]

TASK: [caps-lock-remapped-to-control | Remap Caps Lock to Control] ************ 
changed: [0.0.0.0]

TASK: [iterm | Download iTerm] ************************************************ 
changed: [0.0.0.0]

TASK: [iterm | Extract iTerm zip archive] ************************************* 
changed: [0.0.0.0]

TASK: [iterm | Copy iTerm.app to Applications directory] ********************** 
failed: [0.0.0.0] => {"failed": true, "parsed": false}
invalid output was: [sudo via ansible, key=rbgqmziznqrxlpfepuridnfjrdhldtgr] password: 


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @~/main.retry

0.0.0.0                    : ok=6    changed=3    unreachable=0    failed=1   

This is due to this section in the item play.

- name: Copy iTerm.app to Applications directory
  command: >
    cp -R {{ downloads_directory }}/iTerm2-1_0_0_20131221-nightly/iTerm.app /Applications
    creates=/Applications/iTerm.app
  sudo: yes

@AnneTheAgile
Copy link
Author

i think this is the same can't ssh to self problem.
http://superuser.com/questions/775764/no-route-to-host-i-can-ssh-to-myself-via-the-ip-my-router-assigns-me-but-not-to

Mac needs SSH allowed for service to be on, via prefs / remote login.
http://bluishcoder.co.nz/articles/mac-ssh.html

However, that assigned an IP, which is not all 0's. It shows a message in the GUI.
To log in to this computer remotely, type "ssh THEUID@THEIP"

@AnneTheAgile
Copy link
Author

Local not the bug.

$ cat hosts
#localhost
#127.0.0.1
# Zeroes would not ssh to self ? 
# http://superuser.com/questions/775764/no-route-to-host-i-can-ssh-to-myself-via-the-ip-my-router-assigns-me-but-not-to
0.0.0.0
# Zeroes are hard-coded elsewhere in plays
$ mv hosts hosts-0000
$ nano main.yml 
$ head main.yml

---
# Fix to let local work without ssh to self.
# Do not use 0000 but localhost from inventory file.
# - hosts: 0.0.0.0
- hosts: localhost
  connection: local
  vars:
    home_directory: /Users/{{ ansible_user_id }}
    downloads_directory: /{{ home_directory }}/.ansible/downloads
  roles:
$ ansible-playbook main.yml -i hosts 
ERROR: Unable to find an inventory file, specify one with -i ?
$ ansible-playbook main.yml -i inventory 

PLAY [localhost] ************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [localhost]

TASK: [ansible-download-directory | Ensure the Ansible downloads directory exists] *** 
ok: [localhost]

TASK: [ssh-directory | Ensure the user SSH directory exists] ****************** 
ok: [localhost]

TASK: [caps-lock-remapped-to-control | Remap Caps Lock to Control] ************ 
changed: [localhost]

TASK: [iterm | Download iTerm] ************************************************ 
ok: [localhost]

TASK: [iterm | Extract iTerm zip archive] ************************************* 
skipping: [localhost]

TASK: [iterm | Copy iTerm.app to Applications directory] ********************** 
failed: [localhost] => {"failed": true, "parsed": false}
invalid output was: [sudo via ansible, key=ekxuaiiqdxdzlmafageygnpjncmmxbum] password: 


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/annemoroney/main.retry

localhost                  : ok=5    changed=1    unreachable=0    failed=1   

@AnneTheAgile
Copy link
Author

Similar error to mine

TASK: [iterm | Copy iTerm.app to Applications directory] ********************** 
failed: [localhost] => {"failed": true, "parsed": false}
invalid output was: [sudo via ansible, key=jetqegsfycbziqzacdjdezbbckrfjeco] password:

His;
https://groups.google.com/forum/#!topic/ansible-project/jwe2cd8Dsqk

Another take;
http://serverfault.com/questions/560106/how-can-i-implement-ansible-with-per-host-passwords-securely

@AnneTheAgile
Copy link
Author

command "cp -R {{ downloads_directory }}/iTerm2-1_0_0_20131221-nightly/iTerm.app /Applications
creates=/Applications/iTerm.app sudo: yes"

http://stackoverflow.com/questions/23945201/how-to-run-only-one-task-in-ansible-playbook

Details and for just the trouble part.

$ cat roles/iterm/tasks/main.yml 

---
- name: Download iTerm
  # Get a stable build.  
  # BUG now the hard-coded version is wrong.
  get_url: >
    url=https://iterm2.com/downloads/beta/iTerm2-1_0_0_20140629.zip
     dest={{ downloads_directory }}/iTerm2-1_0_0_20131221-nightly.zip

- name: Extract iTerm zip archive
  command: >
    chdir={{ downloads_directory }}
    unzip iTerm2-1_0_0_20131221-nightly.zip -d iTerm2-1_0_0_20131221-nightly
    creates=iTerm2-1_0_0_20131221-nightly

- name: Copy iTerm.app to Applications directory
  command: >
    cp -R {{ downloads_directory }}/iTerm2-1_0_0_20131221-nightly/iTerm.app /Applications
    creates=/Applications/iTerm.app
  sudo: yes
  tags: 
    - test1
$ ansible-playbook main.yml -i inventory  --tags "test1" -vvvv

PLAY [localhost] ************************************************************** 

GATHERING FACTS *************************************************************** 
<localhost> REMOTE_MODULE setup
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1408206855.01-267449430020410 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1408206855.01-267449430020410 && echo $HOME/.ansible/tmp/ansible-tmp-1408206855.01-267449430020410']
<localhost> PUT /var/folders/9l/0_6s7mts36947gx_tndtzhj00000gn/T/tmpmRSWTP TO ~/.ansible/tmp/ansible-tmp-1408206855.01-267449430020410/setup
<localhost> EXEC ['/bin/sh', '-c', u'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python ~/.ansible/tmp/ansible-tmp-1408206855.01-267449430020410/setup; rm -rf ~/.ansible/tmp/ansible-tmp-1408206855.01-267449430020410/ >/dev/null 2>&1']
ok: [localhost]

TASK: [iterm | Copy iTerm.app to Applications directory] ********************** 
<localhost> REMOTE_MODULE command cp -R //Users/annemoroney/.ansible/downloads/iTerm2-1_0_0_20131221-nightly/iTerm.app /Applications creates=/Applications/iTerm.app
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1408206855.2-70048671704259 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1408206855.2-70048671704259 && echo $HOME/.ansible/tmp/ansible-tmp-1408206855.2-70048671704259']
<localhost> PUT /var/folders/9l/0_6s7mts36947gx_tndtzhj00000gn/T/tmpQIzc76 TO ~/.ansible/tmp/ansible-tmp-1408206855.2-70048671704259/command
<localhost> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=vnowzcqwkzxkruvrnnukvqkxkeyuumbu] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-vnowzcqwkzxkruvrnnukvqkxkeyuumbu; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python ~/.ansible/tmp/ansible-tmp-1408206855.2-70048671704259/command; rm -rf ~/.ansible/tmp/ansible-tmp-1408206855.2-70048671704259/ >/dev/null 2>&1'"'"''
failed: [localhost] => {"failed": true, "parsed": false}
invalid output was: [sudo via ansible, key=vnowzcqwkzxkruvrnnukvqkxkeyuumbu] password: 


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @~/main.retry

localhost                  : ok=1    changed=0    unreachable=0    failed=1   

@AnneTheAgile
Copy link
Author

http://spencer.gibb.us/blog/2014/02/03/introducing-battleschool/

$ sudo pip install battleschool

Password:
Downloading/unpacking battleschool
  Downloading battleschool-0.3.5.tar.gz
  Running setup.py (path:/private/tmp/pip_build_root/battleschool/setup.py) egg_info for package battleschool

Requirement already satisfied (use --upgrade to upgrade): ansible in /Library/Python/2.7/site-packages (from battleschool)
Requirement already satisfied (use --upgrade to upgrade): jinja2 in /Library/Python/2.7/site-packages (from battleschool)
Requirement already satisfied (use --upgrade to upgrade): pyyaml in /Library/Python/2.7/site-packages (from battleschool)
Requirement already satisfied (use --upgrade to upgrade): paramiko in /Library/Python/2.7/site-packages (from ansible->battleschool)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from ansible->battleschool)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.6 in /Library/Python/2.7/site-packages (from ansible->battleschool)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in /Library/Python/2.7/site-packages (from jinja2->battleschool)
Installing collected packages: battleschool
  Running setup.py install for battleschool
    changing mode of build/scripts-2.7/battle from 644 to 755

    changing mode of /usr/local/bin/battle to 755
Successfully installed battleschool
Cleaning up...
$
....

@AnneTheAgile
Copy link
Author

At this point, after strategic deletion,
Normal Prep

$ battle --ask-sudo-pass
sudo password: 
...//etc
## Executing playbook /Users/annemoroney/Library/Caches/battleschool/osx/java6.yml ############################### 
    Task OK: setup
    Task FAILED: mac_pkg failed to install com.apple.pkg.JavaForMacOSX107: rc: 1, , err: hdiutil: attach failed - image not recognized

    Failed playbook:~/Library/Caches/battleschool/osx/java6.yml
           to retry, use: --limit @~/java6.retry

    Playbook FAILED, ok=1, changed=0, unreachable=0, failed=1
$ # deleted alfred and also java 6, 7

Battleschool installs!
Normal see need a config.

$ battle --ask-sudo-pass
sudo password: 
Traceback (most recent call last):
  File "/usr/local/bin/battle", line 337, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/bin/battle", line 167, in main
    config_data = utils.parse_yaml_from_file(config_path)
  File "/Library/Python/2.7/site-packages/ansible/utils/__init__.py", line 668, in parse_yaml_from_file
    raise errors.AnsibleError("file could not read: %s" % path)
ansible.errors.AnsibleError: file could not read: ~//.battleschool/config.yml

~$ mkdir ~/.battleschool
~$ cd .battleschool/
~/.battleschool$ curl -L https://db.tt/aG2uyydU > config.yml   
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   396    0   396    0     0    555      0 --:--:-- --:--:-- --:--:--   556
100   925  100   925    0     0    886      0  0:00:01  0:00:01 --:--:--  2811
~/.battleschool$ nano config.yml 

~/.battleschool$ curl -L https://db.tt/VcyI9dvr > playbook.yml   
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   420    0   420    0     0    456      0 --:--:-- --:--:-- --:--:--   456
100  2047  100  2047    0     0   1590      0  0:00:01  0:00:01 --:--:--  6603
~/.battleschool$

Now with configs.

~/.battleschool$ nano playbook.yml 
~/.battleschool$ battle --ask-sudo-pass
sudo password: 
## Updating sources ############################################################################################## 
    Task OK: git
## Executing playbook ~//Library/Caches/battleschool/osx/local.yml ############################### 
    Task OK: setup
    Task OK: debug: in spencer-gibb/ansible-osx/local.yml
    Playbook OK, ok=2, changed=0, unreachable=0, failed=0
## Executing playbook ~//Library/Caches/battleschool/osx/homebrew.yml ############################ 
    Task OK: setup
    Task OK: mac_pkg: installed package /usr/local/bin/brew
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Executing playbook ~//Library/Caches/battleschool/osx/vagrant.yml ############################# 
    Task OK: setup
    Task OK: mac_pkg: installed package com.vagrant.vagrant
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Executing playbook ~//Library/Caches/battleschool/osx/virtualbox.yml ########################## 
    Task OK: setup
    Task OK: mac_pkg: installed package org.virtualbox.pkg.virtualbox
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Executing playbook ~//Library/Caches/battleschool/osx/alfred.yml #####


$ battle --ask-sudo-pass
sudo password: 
## Updating sources ############################################################################################## 
    Task OK: git
## Executing playbook ~/Library/Caches/battleschool/osx/local.yml ############################### 
    Task OK: setup
    Task OK: debug: in spencer-gibb/ansible-osx/local.yml
    Playbook OK, ok=2, changed=0, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/homebrew.yml ############################ 
    Task OK: setup
    Task OK: mac_pkg: installed package /usr/local/bin/brew
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/vagrant.yml ############################# 
    Task OK: setup
    Task OK: mac_pkg: package com.vagrant.vagrant already present
    Playbook OK, ok=2, changed=0, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/virtualbox.yml ########################## 
    Task OK: setup
    Task OK: mac_pkg: package org.virtualbox.pkg.virtualbox already present
    Playbook OK, ok=2, changed=0, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/dropbox.yml ############################# 
    Task OK: setup
    Task OK: mac_pkg: package /Applications/Dropbox.app already present
    Playbook OK, ok=2, changed=0, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/iterm2.yml ############################## 
    Task OK: setup
    Task OK: mac_pkg: installed package /Applications/iTerm.app
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/better-touch-tool.yml ################### 
    Task OK: setup
    Task OK: mac_pkg: installed package /Applications/BetterTouchTool.app
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Executing playbook ~/Library/Caches/battleschool/osx/adium.yml ############################### 
    Task OK: setup
    Task OK: mac_pkg: installed package /Applications/Adium.app
    Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Battleschool completed ######################################################################################## 

Blog ;
http://spencer.gibb.us/blog/2014/02/03/introducing-battleschool/
Main repo;
https://github.com/spencergibb/battleschool
Dependency repo;
https://github.com/spencergibb/ansible-osx

@AnneTheAgile
Copy link
Author

~/.battleschool files.

$ cat config.yml 

---
cache_dir: ~/Library/Caches/battleschool

sources:
  local:
    - playbook.yml

#  url:
#    - name: playbook.yml
#      url: https://db.tt/VcyI9dvr

  git:
    - name: 'osx'
      repo: 'https://github.com/spencergibb/ansible-osx'
      playbooks:
         - homebrew.yml                 #must come before any use of homebrew module
         #- macports.yml                #must come before any use of macports module
         - vagrant.yml
         - virtualbox.yml
         #- alfred.yml
         #- chrome-beta.yml
         - dropbox.yml
         #- intellij-idea-ultimate13.yml
         #- java7.yml
         #- java6.yml
         - iterm2.yml
         #- macvim.yml
         - better-touch-tool.yml
         - adium.yml
         #- github.yml
         #- gitx.yml
         #- libreoffice.yml
         #- sequel-pro.yml
         #- skype.yml
         #- truecrypt.yml
         #- usb-overdrive.yml
         #- xtra-finder.yml
$ cat playbook.yml 

---
- hosts: workstation

  tasks:
    - name: print from playbook
      debug: msg="in playbooks/playbook.yml"

    - name: easy install pip
      easy_install: name=pip
      sudo: yes

    - name: install apps from pip
      pip: name={{item}}
      sudo: yes
      with_items:
          - virtualenv
          - cliff
          - pyyaml
          - awscli

    - name: install apps from homebrew
      homebrew: name={{item}} state=present
      with_items:
          - coreutils
          - git
          - node
          - maven
          - rbenv
          - dos2unix
          - ruby
          - tomcat
          - wget
          - ctags
          - dnsmasq

    # requires node/npm from above
    - name: install global apps from npm
      npm: name={{item}} global=yes
      with_items:
          - grunt-cli

#    - name: create homdir symlinks
#      file: src={{item.from}} dest={{item.to}} state=link
#      sudo: no
#      with_items:
#         - from: ~/Dropbox/ubuntu/.bash_aliases
#           to: ~/.bash_aliases
#         - from: ~/Dropbox/ubuntu/.bash_logout
#           to: ~/.bash_logout
#         - from: ~/Dropbox/ubuntu/.bashrc
#           to: ~/.bashrc
#         - from: ~/Dropbox/mac/battleschool
#           to: ~/.battleschool
#         - from: ~/Dropbox/ubuntu/.ctags
#           to: ~/.ctags
#         - from: ~/Dropbox/ubuntu/.gitconfig
#           to: ~/.gitconfig
#         - from: ~/Dropbox/ubuntu/.inputrc
#           to: ~/.inputrc
#         - from: ~/Dropbox/ubuntu/.profile
#           to: ~/.profile
#         - from: ~/Dropbox/ubuntu/.todo
#           to: ~/.todo
#         - from: ~/Dropbox/ubuntu/.vimrc
#           to: ~/.vimrc
#         - from: ~/Dropbox/ubuntu/.zsh
#           to: ~/.zsh
#         - from: ~/Dropbox/ubuntu/.zshrc
#           to: ~/.zshrc
#         - from: ~/Dropbox/mac/bin
#           to: ~/bin
#         - from: ~/Google\ Drive
#           to: ~/drive



#    - name: install gems
#      gem: name={{item}} state=latest
#      with_items:
#          - brewbygems
#          - bundler
#          - compass

@AnneTheAgile
Copy link
Author

# Bash Heredoc put into a file (not a variable)
$ cat <<EOF > myfile
> [workstation]
> localhost
> EOF
$ ls m*
myfile

# Ansible inventory file must exist and if use local, no ssh required
$ ansible all  -m ping -i ansinv  
localhost | success >> {
    "changed": false, 
    "ping": "pong"
}

$ cat ansinv 
[workstation]
localhost ansible_connection=local 
# no ssh needed with local ansi connection, aka -c local, but couldn't get cli to work.

In this bootstrap, it uses ssh-copy-id which is not installed on mac, and then makes a user 'ansible' which perhaps defeats the value of having individual uids.
https://github.com/serenecloud/ansible-bootstrap/blob/master/ansible_bootstrap.sh

@AnneTheAgile
Copy link
Author

Erase disk partition, make mac os extended journaled.
From USB, run an osx 10.9.4 fresh install, taking 1.5hours.
No internet.
Login, turn on internet but no apple login.
Easy_install pip, with sudo.
Git exists but will not work due to no Xcode tools.
Run pip install battle school; get error about compile. Click OK to install Xcode dev tools.
Xcode itself remains uninstalled. No pkg found / seen. Clang is ok?

Do not need SSH for self, if follow above, must have inventory file.
Git clone works ok now on a public item.
[]get template config

@AnneTheAgile
Copy link
Author

Inventory file for localhost without SSH;
https://gist.githubusercontent.com/AnneTheAgile/cbd42fab4563ed1ae024/raw/75a1000f6f68774630289bbd6d8c36fd671bf873/talk-battle-inv.yml

Empty config that calls no play books for startup via bootstrapped;
https://gist.githubusercontent.com/AnneTheAgile/071ce60cc5205b133db4/raw/99fffb034158c39630617104d45ae69e730a98fc/talk-battle-config-empty.yml

Bootstrapper part 1, gets the environment var (not used yet, for SSH) and get the basic config.
https://gist.githubusercontent.com/AnneTheAgile/5e6666bd2e2c25890e1e/raw/0e1e2e542c84ab1e01101fe1651a6afd39b82240/talk-battle-ansi-config

$ ansible-playbook -i ansinv  ansiboot.yml

PLAY [workstation] ************************************************************ 

GATHERING FACTS *************************************************************** 
ok: [localhost]

TASK: [BattleSchool Hidden Folder is created.] ******************************** 
changed: [localhost]

TASK: [BattleSchool Configuration Initialization.] **************************** 
changed: [localhost]

TASK: [Ensure git clone file gist worked.] ************************************ 
ok: [localhost]

PLAY RECAP ******************************************************************** 
localhost                  : ok=4    changed=2    unreachable=0    failed=0   

[]Some SSH creation code is embedded in here;
https://github.com/serenecloud/ansible-bootstrap/blob/master/ansible_bootstrap.sh

[]Make an ad-hoc command line of this all ?

[]Run one each of real items?

[]Run get info on Dock etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment