-
-
Save AnneTheAgile/7a26c63b134c3b1214b6 to your computer and use it in GitHub Desktop.
--- | |
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 | |
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
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
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
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...
$
....
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
~/.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
# 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
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
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.
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"