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
    7.9k
    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.
    • IRJI
      IRJ
      last edited by

      sudo ansible-galaxy install

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

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

        sudo ansible-galaxy install

        sudo ansible-galaxy install geerlingguy.homebrew
         [WARNING]: - geerlingguy.homebrew (2.9.0) is already installed - use --force to change version to unspecified
        
        1 Reply Last reply Reply Quote 0
        • DustinB3403D
          DustinB3403
          last edited by

          This is the galaxy page https://galaxy.ansible.com/geerlingguy/homebrew

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

            Are you running this from /etc/ansible/ ?

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

              @IRJ yes.

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

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

                #***********************************************************
                # Create or append ansible requirements file
                #***********************************************************
                
                
                sudo sh -c "echo '- src: /etc/ansible/apple.yml' >> /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
                IRJI 1 Reply Last reply Reply Quote 0
                • DustinB3403D
                  DustinB3403
                  last edited by

                  By default it installs to /root/.ansible/roles/geerlingguy.homebrew/ rather than into /etc/ansible/roles

                  So I copied the file to /etc/ansible/roles

                  When running the playbook I get

                  ERROR! the playbook: apple.yml could not be found
                  
                  1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403
                    last edited by

                    This is the sample playbook I'm testing with.

                    ---
                    
                    - name: Installing 1Password
                    connection: network_cli
                    gather_facts: false
                    hosts: apple_workstations
                    vars:
                        homebrew_installed_packages:
                        - 1password
                    roles:
                        - geerlineguy.homebrew
                    

                    This yaml file is located at /etc/ansible/apple.yml

                    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:

                      This is the sample playbook I'm testing with.

                      ---
                      
                      - name: Installing 1Password
                      connection: network_cli
                      gather_facts: false
                      hosts: apple_workstations
                      vars:
                          homebrew_installed_packages:
                          - 1password
                      roles:
                          - geerlineguy.homebrew
                      

                      This yaml file is located at /etc/ansible/apple.yml

                      Try the commands I posted above

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

                        sudo sh -c "echo '- src: /etc/ansible/apple.yml' >>                                                                                                                                                              /etc/ansible/requirements.yml"
                        [root@rocansible01 ansible]# pwd
                        /etc/ansible
                        [root@rocansible01 ansible]# sudo ansible-galaxy install -p roles -r /etc/ansibl                                                                                                                                                             e/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.
                        [root@rocansible01 ansible]# sudo ansible-playbook /etc/ansible/apple.yml
                        ERROR! the role 'geerlineguy.homebrew' was not found in /etc/ansible/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/                                                                                                               ansible/roles:/etc/ansible
                        
                        The error appears to be in '/etc/ansible/apple.yml': line 11, column 7, but may
                        be elsewhere in the file depending on the exact syntax problem.
                        
                        The offending line appears to be:
                        
                        roles:
                            - geerlineguy.homebrew
                            ^ here
                        
                        [root@rocansible01 ansible]#
                        
                        1 Reply Last reply Reply Quote 0
                        • DustinB3403D
                          DustinB3403
                          last edited by DustinB3403

                          So even without the role (working or my lack of understanding on how to use it), Ansible is starting to look pretty damn nice. No dealing with VNC tools or ARD, sending ad-hoc commands is pretty damn simple too and would solve a large portion of the issues I forsee.

                          Monthly updates for example.

                          It would be nice to be able to run the tertiary software updates as well with brew, and I'm still figuring that part out, but this might be a long term solution.

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

                            Skip the roles for now just delete that from you apple.yml

                            Try just this

                            ---
                            
                            - name: Installing 1Password
                            connection: network_cli
                            gather_facts: false
                            hosts: apple_workstations
                            vars:
                                homebrew_installed_packages:
                                - 1password
                            
                            1 Reply Last reply Reply Quote 0
                            • DustinB3403D
                              DustinB3403
                              last edited by DustinB3403

                               [WARNING]: Unable to parse /etc/ansible/x.x.x.143 as an inventory source
                              
                               [WARNING]: No inventory was parsed, only implicit localhost is available
                              
                               [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
                              
                               ERROR! Syntax Error while loading YAML.
                               mapping values are not allowed in this context
                              
                               The error appears to be in '/etc/ansible/apple.yml': line 4, column 15, but may
                               be elsewhere in the file depending on the exact syntax problem.
                              
                               The offending line appears to be:
                              
                               -name: Installing 1Password
                              	 connection: network_cli
                                  	             ^ here
                              

                              Have a syntax error, but my yaml file certainly appears correct.

                              --- 
                              
                              -name: Installing 1Password
                                  connection: network_cli
                                  gather_facts: false
                                  hosts: x.x.x.143
                                  vars:
                                  homebrew_installed_packages:
                                  - 1password
                              
                              black3dynamiteB 1 Reply Last reply Reply Quote 0
                              • black3dynamiteB
                                black3dynamite @DustinB3403
                                last edited by

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

                                [WARNING]: Unable to parse /etc/ansible/x.x.x.143 as an inventory source

                                [WARNING]: No inventory was parsed, only implicit localhost is available

                                [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

                                ERROR! Syntax Error while loading YAML.
                                mapping values are not allowed in this context

                                The error appears to be in '/etc/ansible/apple.yml': line 4, column 15, but may
                                be elsewhere in the file depending on the exact syntax problem.

                                The offending line appears to be:

                                -name: Installing 1Password
                                connection: network_cli
                                ^ here

                                Have a syntax error, but my yaml file certainly appears correct.

                                --- 
                                
                                -name: Installing 1Password
                                    connection: network_cli
                                    gather_facts: false
                                    hosts: x.x.x.143
                                    vars:
                                    homebrew_installed_packages:
                                    - 1password
                                

                                -name -> - name

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

                                  @black3dynamite didn't fix it.

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

                                    So I know this will likely light a flame for someone, but when in the hell is yaml so annoying?

                                    @IRJ how do I check my yaml configuration using the software you recommended, both VSCode and the extension are installed - just not sure how the heck to use yet.

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

                                      Okay so in using the test.yaml file buried within the geerlingguy folder I was able to at least get some progress.

                                      ansible-playbook -i hosts apple.yml
                                      
                                      PLAY [x.x.x.143] ***********************************************************************************************************************************************************************************************************************
                                      
                                      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
                                      

                                      But doesn't seem to install based on what's in the apple.yml file

                                      ---
                                      - hosts: 1x.x.x.143
                                        vars:
                                      	homebrew_clear_cache: true
                                      	homebrew_installed_packages:
                                      	  - ssh-copy-id  # from homebrew/core
                                      	  - nginx-full  # from dengi/nginx
                                      	homebrew_cask_apps:
                                      	  - 1Password # from hombrew/cask
                                      
                                      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:

                                        Okay so in using the test.yaml file buried within the geerlingguy folder I was able to at least get some progress.

                                        ansible-playbook -i hosts apple.yml

                                        PLAY [x.x.x.143] ***********************************************************************************************************************************************************************************************************************

                                        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

                                        But doesn't seem to install based on what's in the apple.yml file


                                        • hosts: 1x.x.x.143
                                          vars:
                                          homebrew_clear_cache: true
                                          homebrew_installed_packages:
                                          - ssh-copy-id # from homebrew/core
                                          - nginx-full # from dengi/nginx
                                          homebrew_cask_apps:
                                          - 1Password # from hombrew/cask

                                        Oh! I thought you were only using a single file.

                                        Ok let's back up. can you show the folder structure of geerlingguy folder?

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

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

                                          So I know this will likely light a flame for someone, but when in the hell is yaml so annoying?

                                          @IRJ how do I check my yaml configuration using the software you recommended, both VSCode and the extension are installed - just not sure how the heck to use yet.

                                          It shows you when there is a formatting error

                                          No error
                                          8c0469e6-072d-4be0-b8d4-7a58e784f528-image.png

                                          Error. File lights up red and gives you a tip on how to fix.

                                          a8a48982-24ad-40e9-a794-cdaf1bd2c2a8-image.png

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

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

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

                                            Okay so in using the test.yaml file buried within the geerlingguy folder I was able to at least get some progress.

                                            ansible-playbook -i hosts apple.yml
                                            
                                            PLAY [x.x.x.143] ***********************************************************************************************************************************************************************************************************************
                                            
                                            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
                                            

                                            But doesn't seem to install based on what's in the apple.yml file

                                            ---
                                            - hosts: 1x.x.x.143
                                            vars:
                                              homebrew_clear_cache: true
                                              homebrew_installed_packages:
                                                - ssh-copy-id  # from homebrew/core
                                                - nginx-full  # from dengi/nginx
                                              homebrew_cask_apps:
                                                - 1Password # from hombrew/cask
                                            

                                            Oh! I thought you were only using a single file.

                                            Ok let's back up. can you show the folder structure of geerlingguy folder?

                                            To summarize, everything is installed in the default locations.

                                            tree /etc/ansible/
                                            /etc/ansible/
                                            ├── ansible.cfg
                                            ├── apple.yml
                                            ├── clients
                                            ├── hosts
                                            ├── requirements.yml
                                            ├── roles
                                            │   └── 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
                                            
                                            8 directories, 17 files
                                            
                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 3 / 5
                                            • First post
                                              Last post