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

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