ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Using Ansible to Manage install and update Apple OSX DHCP clients

    IT Discussion
    osx ansible homebrew apple automation
    5
    100
    8.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403
      last edited by

      This is the updated apply.yml file

      ---
      - hosts: apple_workstations
        vars:
      	homebrew_repo: https://github.com/Homebrew/brew
      	homebrew_prefix: /usr/local
      	homebrew_install_path: "{{ homebrew_prefix }}/Homebrew"
      	homebrew_bin_path: /usr/local/bin
      	homebrew_clear_cache: true
      	homebrew_installed_packages:
      	  - ssh-copy-id  # from homebrew/core
      	  - nginx-full  # from dengi/nginx
      	homebrew_cask_apps:
      	  - 1password
      	homebrew_taps:
      	  - homebrew/cask
      	  - { name: denji/nginx, url: 'https://github.com/denji/homebrew-nginx.git' }
      	homebrew_cask_accept_external_apps: true
      	homebrew_cask_appdir: /Applications
      

      It runs without issue, but doesn't actually install 1password

      1 Reply Last reply Reply Quote 0
      • IRJI
        IRJ @IRJ
        last edited by

        @IRJ said in Using Ansible to Manage install and update Apple OSX DHCP clients:

        Ok let's try this. Is your playbook only one file?

        #***********************************************************
        # Create or append ansible requirements file
        #***********************************************************
        
        
        sudo sh -c "echo '- src: /etc/ansible/roles/geerlineguy' >> /etc/ansible/requirements.yml"
        
        #***********************************************************
        # Install the role
        #***********************************************************
        
        cd /etc/ansible/
        sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
        
        #***********************************************************
        # Run ansible playbook file
        #***********************************************************
        
        sudo ansible-playbook /etc/ansible/apple.yml
        

        Updated. try this

        DustinB3403D 1 Reply Last reply Reply Quote 0
        • DustinB3403D
          DustinB3403 @IRJ
          last edited by

          @IRJ Each command individually?

          IRJI 1 Reply Last reply Reply Quote 0
          • IRJI
            IRJ @DustinB3403
            last edited by

            @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

            @IRJ Each command individually?

            yes reinstall the role this way

            DustinB3403D 1 Reply Last reply Reply Quote 0
            • DustinB3403D
              DustinB3403 @IRJ
              last edited by

              @IRJ So wouldn't I have to delete the role first?

              IRJI 1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403
                last edited by

                Also this fails.

                sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                 [WARNING]: - /etc/ansible/apple.yml was NOT installed successfully: the file downloaded was not a tar.gz
                
                ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
                
                IRJI 1 Reply Last reply Reply Quote 0
                • IRJI
                  IRJ @DustinB3403
                  last edited by

                  @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                  @IRJ So wouldn't I have to delete the role first?

                  Just try running it first. If you delete the role, then the reference to source file will break.

                  1 Reply Last reply Reply Quote 0
                  • IRJI
                    IRJ @DustinB3403
                    last edited by

                    @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                    Also this fails.

                    sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                    [WARNING]: - /etc/ansible/apple.yml was NOT installed successfully: the file downloaded was not a tar.gz

                    ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

                    let me see your /etc/ansible/requirements.yml

                    1 Reply Last reply Reply Quote 0
                    • DustinB3403D
                      DustinB3403
                      last edited by

                      cat /etc/ansible/requirements.yml
                      - src: /etc/ansible/apple.yml
                      - src: /etc/ansible/apple.yml
                      - src: /etc/ansible/roles/geerlineguy
                      
                      IRJI 1 Reply Last reply Reply Quote 0
                      • IRJI
                        IRJ @DustinB3403
                        last edited by

                        @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                        cat /etc/ansible/requirements.yml
                        - src: /etc/ansible/apple.yml
                        - src: /etc/ansible/apple.yml
                        - src: /etc/ansible/roles/geerlineguy
                        

                        get rid of the first two entries

                        DustinB3403D 1 Reply Last reply Reply Quote 0
                        • DustinB3403D
                          DustinB3403 @IRJ
                          last edited by

                          @IRJ just did, not sure why they're in there as I haven't touched this file.

                          IRJI 1 Reply Last reply Reply Quote 0
                          • IRJI
                            IRJ @DustinB3403
                            last edited by

                            @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                            @IRJ just did, not sure why they're in there as I haven't touched this file.

                            They are there because we did echo command in script to add them.

                            1 Reply Last reply Reply Quote 0
                            • DustinB3403D
                              DustinB3403
                              last edited by

                              sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml
                              - downloading role '/etc/ansible/roles/geerlineguy', owned by
                               [WARNING]: - /etc/ansible/roles/geerlineguy was NOT installed successfully: Content has no field named 'owner'
                              
                              ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
                              
                              IRJI 1 Reply Last reply Reply Quote 0
                              • IRJI
                                IRJ @DustinB3403
                                last edited by

                                @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                sudo ansible-galaxy install -p roles -r /etc/ansible/requirements.yml

                                • downloading role '/etc/ansible/roles/geerlineguy', owned by
                                  [WARNING]: - /etc/ansible/roles/geerlineguy was NOT installed successfully: Content has no field named 'owner'

                                ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

                                We need the master @stacksofplates

                                1 Reply Last reply Reply Quote 0
                                • DustinB3403D
                                  DustinB3403
                                  last edited by

                                  Running ansible-playbook -i hosts apple.yml

                                   ansible-playbook -i hosts apple.yml
                                  
                                  PLAY [apple_workstations] *******************************************************************************************************************************************************************************************************************
                                  
                                  TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
                                  ok: [x.x.x.143]
                                  
                                  PLAY RECAP **********************************************************************************************************************************************************************************************************************************
                                  x.x.x.143             : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
                                  

                                  So I think the playbook and role are installed correctly.

                                  IRJI 1 Reply Last reply Reply Quote 0
                                  • IRJI
                                    IRJ @DustinB3403
                                    last edited by

                                    @DustinB3403 said in Using Ansible to Manage install and update Apple OSX DHCP clients:

                                    Running ansible-playbook -i hosts apple.yml

                                    ansible-playbook -i hosts apple.yml

                                    PLAY [apple_workstations] *******************************************************************************************************************************************************************************************************************

                                    TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
                                    ok: [x.x.x.143]

                                    PLAY RECAP **********************************************************************************************************************************************************************************************************************************
                                    x.x.x.143 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

                                    So I think the playbook and role are installed correctly.

                                    what changed?

                                    DustinB3403D 1 Reply Last reply Reply Quote 0
                                    • DustinB3403D
                                      DustinB3403 @IRJ
                                      last edited by

                                      @IRJ I used the test.yml file from within the geerlingguy tests folder.

                                      I stated this up above.

                                      What doesn't appear to work is anything actually being installed. . .

                                      1 Reply Last reply Reply Quote 0
                                      • stacksofplatesS
                                        stacksofplates
                                        last edited by

                                        Ok I'm eating dinner and I'll make a post afterwards.

                                        1 Reply Last reply Reply Quote 0
                                        • stacksofplatesS
                                          stacksofplates
                                          last edited by stacksofplates

                                          Ok. I made a skeleton repo for you here. This is how I set up all of my playbooks. I use a single repo for most of my playbooks and then the roles have their own repositories (because they're called in with Galaxy). I never use the /etc/ansible directory because of permissions issues and it's not portable. You can take this one step further and use a virtualenv but that's for later after you get this working.

                                          It will be easiest if you fork this and have your own. Clone your copy locally and then put your playbook(s) in the top level folder of the repository. In the inventory directory, add a file called macs or whatever your group is called, but still add the group name in the file like you would normally. It's just a nice way to be able to separate things out logically so you can see them easier. Also add any group_vars if you have them.

                                          Add your role to the roles/requirements.yml file. Once you've added all of your files to your repo, commit your changes. Then run make roles. It will remove any roles you've installed, and then reinstall them. Now you should be ready to run the playbook.

                                          You can also run make clean and it will reset your repository to the latest commit. So if you want to keep the work make sure to commit.

                                          1 Reply Last reply Reply Quote 2
                                          • DustinB3403D
                                            DustinB3403
                                            last edited by DustinB3403

                                            Okay so this is my existing tree.

                                            /etc/ansible/
                                            ├── ansible.cfg
                                            ├── apple.yml
                                            ├── clients
                                            ├── default.config.yml
                                            ├── hosts
                                            ├── main.yml
                                            ├── playbook-skeleton
                                            │   ├── ansible.cfg
                                            │   ├── group_vars
                                            │   │   └── README
                                            │   ├── inventory
                                            │   │   ├── apple_workstations
                                            │   │   └── dev
                                            │   ├── library
                                            │   │   └── README
                                            │   ├── Makefile
                                            │   └── roles
                                            │       └── requirements.yml
                                            ├── requirements.yml
                                            ├── roles
                                            │   ├── ansible-role-homebrew
                                            │   │   ├── defaults
                                            │   │   │   └── main.yml
                                            │   │   ├── handlers
                                            │   │   │   └── main.yml
                                            │   │   ├── LICENSE
                                            │   │   ├── meta
                                            │   │   │   └── main.yml
                                            │   │   ├── README.md
                                            │   │   ├── requirements.yml
                                            │   │   ├── tasks
                                            │   │   │   ├── main.yml
                                            │   │   │   └── playbook.yml
                                            │   │   └── tests
                                            │   │       ├── local-testing
                                            │   │       │   ├── playbook.yml
                                            │   │       │   └── README.md
                                            │   │       └── test.yml
                                            │   ├── elliotweiser.osx-command-line-tools
                                            │   │   ├── ansible.cfg
                                            │   │   ├── CONTRIBUTING.md
                                            │   │   ├── defaults
                                            │   │   │   └── main.yml
                                            │   │   ├── handlers
                                            │   │   │   └── main.yml
                                            │   │   ├── LICENSE
                                            │   │   ├── meta
                                            │   │   │   └── main.yml
                                            │   │   ├── molecule
                                            │   │   │   ├── default
                                            │   │   │   │   ├── create.yml
                                            │   │   │   │   ├── destroy.yml
                                            │   │   │   │   ├── molecule.yml
                                            │   │   │   │   └── prepare.yml
                                            │   │   │   ├── elcapitan.sh
                                            │   │   │   ├── highsierra.sh
                                            │   │   │   ├── mojave.sh
                                            │   │   │   ├── sierra.sh
                                            │   │   │   ├── unset.sh
                                            │   │   │   └── yosemite.sh
                                            │   │   ├── README.md
                                            │   │   ├── tasks
                                            │   │   │   └── main.yml
                                            │   │   ├── tests
                                            │   │   │   ├── inventory
                                            │   │   │   ├── playbook.yml
                                            │   │   │   ├── test_default.py
                                            │   │   │   ├── test-requirements.txt
                                            │   │   │   └── version_check.py
                                            │   │   └── vars
                                            │   │       └── main.yml
                                            │   └── geerlingguy.homebrew
                                            │       ├── defaults
                                            │       │   └── main.yml
                                            │       ├── handlers
                                            │       │   └── main.yml
                                            │       ├── LICENSE
                                            │       ├── meta
                                            │       │   └── main.yml
                                            │       ├── README.md
                                            │       ├── requirements.yml
                                            │       ├── tasks
                                            │       │   ├── main.yml
                                            │       │   └── playbook.yml
                                            │       └── tests
                                            │           ├── local-testing
                                            │           │   ├── playbook.yml
                                            │           │   └── README.md
                                            │           └── test.yml
                                            └── ssh.sh
                                            
                                            29 directories, 61 files
                                            

                                            The make command wasn't found so I installed make. Running make roles from within the /etc/ansible/playbook-skeleton I got

                                            make roles
                                            git clean -fdx roles
                                            ansible-galaxy install -r roles/requirements.yml
                                            - extracting ansible-role-homebrew to /etc/ansible/playbook-skeleton/roles/ansible-role-homebrew
                                            - ansible-role-homebrew was installed successfully
                                            - adding dependency: elliotweiser.osx-command-line-tools
                                            - downloading role 'osx-command-line-tools', owned by elliotweiser
                                            - downloading role from https://github.com/elliotweiser/ansible-osx-command-line-tools/archive/2.2.1.tar.gz
                                            - extracting elliotweiser.osx-command-line-tools to /etc/ansible/playbook-skeleton/roles/elliotweiser.osx-command-line-tools
                                            - elliotweiser.osx-command-line-tools (2.2.1) was installed successfully
                                            
                                            stacksofplatesS 1 Reply Last reply Reply Quote 1
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 5 / 5
                                            • First post
                                              Last post