-
-
Save AnneTheAgile/5e6666bd2e2c25890e1e to your computer and use it in GitHub Desktop.
--- | |
# FILE: talk-battle-ansi-config | |
# README: Prepare a mac 10.9 machine for running battleschool by ensuring a config file/folder exists. | |
# USAGE: $ ansible-playbook -i ansinv ansiboot.yml # Where ansinv= Your inventory file; ansiboot.yml= This script. | |
# PREREQ: | |
# $ curl -L THIS-URL > ~/.battleschool/config.yml # TIP-Bash-Curl: L: If location redirects, go there instead. | |
# $ ansible all -m ping # Test that the inventory file exists and ansible works with local host. | |
# $ ansible workstation -m ping -i ansinv # Test that the given inventory file contains 'workstation'. | |
# NEXT: $ battle --ask-sudo-pass --config-file=/Users/YOURUSER/.battleschool/config.yml # Config is created by this script. | |
# []TODO- Ansible-Battle; IDK why Tilde is not accepted to find path for config file - especially given it defaults ok. | |
# URL: As of 2014-08-23S. | |
# https://gist.githubusercontent.com/AnneTheAgile/5e6666bd2e2c25890e1e/raw/a166f7ed2a27ea71cdca806dcab$ | |
# https://gist.github.com/AnneTheAgile/5e6666bd2e2c25890e1e | |
# FUTURE: []TODO- Add Bash wrapper to get this URL content and run the [usage] step. This is how brew.sh's one-liner works. | |
- hosts: workstation | |
vars: | |
SSHPWD: "{{ lookup('env','MY_PWD') }}" | |
# TIP-Bash-Env: Put Secret passwords (use LastPass) in environment variables, ~/.bashrc. $ export MY_PWD="aSecret" | |
# TODO-SSH: This section is for creating SSH keys during bootstrap-2. | |
tasks: | |
- name: "BattleSchool: Create Hidden Dot Folder for config files - ~/.battleschool/." | |
file: path=~/.battleschool state=directory | |
# TODO-Ansible: IDK when to / not use shell vs command module. Bash flavor may matter. | |
# TIP-Ansible-Yml: Colon in Name cannot be unquoted. | |
- name: "BattleSchool: Create Empty Configuration file for bootstrap initialization - ~/.battleschool/config.yml." | |
get_url: url=https://gist.githubusercontent.com/AnneTheAgile/071ce60cc5205b133db4/raw/3a5b9f3848c00ede0aa8aa1a435ba1eccf7888fc/talk-battle-config-empty.yml | |
dest=~/.battleschool/config.yml | |
# TIP-Battle: Original author's config.yml includes numerous things; https://db.tt/aG2uyydU | |
# TIP-Ansible: Use only get_url, not curl nor git module for gist text files. | |
- name: "BattleSchool: Apply correct permissions to config file - ~/.battleschool/config.yml." | |
file: path=~/.battleschool/config.yml state=file mode=755 | |
# TIP-Bash: chmod = 751 => owner=rwx, all others=rx. | |
# TIP-Battle: Config file must be readable and executable. => Updt; Maybe X-only is ok without Tilde. | |
# TIP-Bash: Chmod's numeric equivalents of text directives. URL: http://www.onlineconversion.com/html_chmod_calculator.htm |
1.[] Modules don't need Paths, shouldn't need them.
https://groups.google.com/forum/#!topic/ansible-project/i_BFBfeZ4Ys
2.[] Nice Example , clearly shows all needed folder structures ; Tells Years of each Config mgmt tool intro inc. Juju.
http://tomoconnor.eu/blogish/getting-started-ansible/#.VDCPOlZ0UfE
3.[] Might need Recursive Sub-Git ; IDK WHY; might have been by mistake I did that.
http://docs.ansible.com/developing_modules.html#testing-modules
4.[] Running play books, another ex. Ubuntu.
https://www.digitalocean.com/community/tutorials/how-to-create-ansible-playbooks-to-automate-system-configuration-on-ubuntu
BUG? Do need Sudo prefix.
$ ansible-playbook -vv -i ~/ansinv -M /usr/share/battleschool/library/ ~/.battleschool/playbooks/adium.yml
PLAY [workstation] ************************************************************
GATHERING FACTS ***************************************************************
<localhost> REMOTE_MODULE setup
ok: [localhost]
TASK: [say-tof] ***************************************************************
ok: [localhost] => {
"msg": "~HOME/.battleschool/playbooks/Adium.yml= Starting!"
}
TASK: [install Firefox] *******************************************************
<localhost> REMOTE_MODULE mac_pkg pkg_type=app url=http://sourceforge.net/projects/adium/files/Adium_1.5.9.dmg/download archive_type=dmg archive_path=Adium.app
failed: [localhost] => {"failed": true, "parsed": false}
[sudo via ansible, key=bzhjymtqnhzygnqgteaneeyeesiqwbfg] password:
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/HOME/adium.retry
localhost : ok=2 changed=0 unreachable=0 failed=1
TODO; Why firefox doesn't fit the model?
https://github.com/spencergibb/battleschool/blob/master/share/library/mac_pkg
https://github.com/spencergibb/ansible-osx/blob/master/adium.yml
Easy to get Adium, the reference app to install.
https://github.com/spencergibb/battleschool/blob/44d53439400b4078e3041013b1f9ee5995fb33bf/test/test_app_dmg.sh
https://github.com/spencergibb/ansible-osx/blob/master/adium.yml
The setup info.
1.[] Ansible Verbose output -v option or -vvv; or debug module.
http://serverfault.com/questions/531891/how-do-i-enable-additional-debugging-output-from-ansible-and-vagrant
2.[] Conditionally execute a task depending on category of Ansible variable.
http://grokbase.com/t/gg/ansible-project/148jmn57w3/ansible-calling-a-playbook-inside-a-playbook-with-vars-prompt-giving-error-error-vars-prompt-is-not-a-legal-parameter-in-an-ansible-task-or-handler
3.[] NOT DONE yet, more complex test.
https://github.com/spencergibb/battleschool/blob/44d53439400b4078e3041013b1f9ee5995fb33bf/test/testconfig/playbooks/playbook.yml
4.[] FIND for mac_pkg
https://github.com/spencergibb/battleschool/search?p=2&q=mac_pkg&type=Code&utf8=✓
5.[] Say hi to all machines; can reverse the order of args.
http://docs.ansible.com/intro_getting_started.html
6.[] Ansible module must have its first line telling the type of language, else get odd failures; if get this failure and you were running a yml playbook, that's because it is not a module!
http://stackoverflow.com/questions/19527867/how-should-script-output-be-formatted-for-ansible-reporting
7.[] Example Shell Bash Ansible module.
http://jpmens.net/2012/07/05/shell-scripts-as-ansible-modules/
8.[] PIP documentation; List=Tell ALL (no args read) related installed; Show X=Details for one; Search=Find on remote all with such words; List --outdated to hunt for new
http://pip.readthedocs.org/en/latest/user_guide.html#listing-packages
9.[] Pip Update
http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip
Bash Tips
1.[] Be sure to run export after changing the Path!
http://www.troubleshooters.com/linux/prepostpath.htm
PATH=$PATH:/data/myscripts
export PATH
2.[] Simple way to edit path is just use editor with output to a file!
http://stackoverflow.com/questions/370047/what-is-the-most-elegant-way-to-remove-a-path-from-the-path-variable-in-bash